Skip to content

Commit

Permalink
lets see how many pass with this
Browse files Browse the repository at this point in the history
  • Loading branch information
jrushlow committed Feb 28, 2024
1 parent 824451f commit ef75722
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 27 deletions.
19 changes: 10 additions & 9 deletions src/Maker/MakeRegistrationForm.php
Expand Up @@ -207,9 +207,15 @@ private function interactAuthenticatorQuestions(ConsoleStyle $io, InteractiveSec
// get list of authenticators
$authenticators = $interactiveSecurityHelper->getAuthenticatorClasses($firewallsData[$firewallName]);

$canLoginAfterRegistration = $this->canSecurityBundleLogin;
if (empty($authenticators)) {
$io->note('No authenticators found - so your user won\'t be automatically authenticated after registering.');

return;
}

$canLoginAfterRegistration = class_exists(Security::class);

if (!$this->canSecurityBundleLogin) {
if (!class_exists(Security::class)) {
foreach ($authenticators as $authenticator) {
if (!$authenticator->isNative()) {
$canLoginAfterRegistration = true;
Expand All @@ -223,12 +229,6 @@ private function interactAuthenticatorQuestions(ConsoleStyle $io, InteractiveSec
return;
}

if (empty($authenticators)) {
$io->note('No authenticators found - so your user won\'t be automatically authenticated after registering.');

return;
}

$this->autoLoginAuthenticator =
1 === \count($authenticators) ? $authenticators[0] : $io->choice(
'Which authenticator\'s should be used to login the user?',
Expand Down Expand Up @@ -367,7 +367,8 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
'authenticator_full_class_name' => $this->autoLoginAuthenticator ? $this->autoLoginAuthenticator->getType() : '',
'firewall_name' => $this->firewallName,
'redirect_route_name' => $this->redirectRouteName,
'password_hasher_class_details' => $generator->createClassNameDetails(UserPasswordHasherInterface::class, '\\'),
'password_hasher_class_details' => $hasherDetails = $generator->createClassNameDetails(UserPasswordHasherInterface::class, '\\'),
'password_hasher_variable_name' => sprintf('$%s', lcfirst($hasherDetails->getShortName())),
'translator_available' => $isTranslatorAvailable,
],
$userRepoVars
Expand Down
Expand Up @@ -25,7 +25,7 @@ public function register(Request $request, <?= $password_hasher_class_details->g
if ($form->isSubmitted() && $form->isValid()) {
// encode the plain password
$user->set<?= ucfirst($password_field) ?>(
$userPasswordHasher->hashPassword(
<?= $password_hasher_variable_name ?>->hashPassword(
$user,
$form->get('plainPassword')->getData()
)
Expand Down
35 changes: 18 additions & 17 deletions src/Security/InteractiveSecurityHelper.php
Expand Up @@ -142,33 +142,34 @@ public function guessPasswordField(SymfonyStyle $io, string $userClass): string
}

/**
* @return AuthenticatorType[]
* @return AuthenticatorTypeEnum[]
*/
public function getAuthenticatorClasses(array $firewallData): array
{
$authenticators = [];

foreach ($firewallData as $potentialAuthenticator => $configData) {
$authenticator = \in_array(strtolower($potentialAuthenticator), AuthenticatorType::getNativeTypes(), true);
$authenticator = AuthenticatorTypeEnum::tryFrom($potentialAuthenticator);
// $authenticator = \in_array(strtolower($potentialAuthenticator), AuthenticatorType::getNativeTypes(), true);

if (false !== $authenticator) {
$authenticators[] = new AuthenticatorType($potentialAuthenticator);
if (null !== $authenticator) {
$authenticators[] = $authenticator;
}
}

if (isset($firewallData['custom_authenticator'])) {
if (\is_string($firewallData['custom_authenticator'])) {
$authenticators[] = new AuthenticatorType($firewallData['custom_authenticator']);

return $authenticators;
}

foreach ($firewallData['custom_authenticator'] as $potentialAuthenticator) {
if (class_exists($potentialAuthenticator)) {
$authenticators[] = new AuthenticatorType($potentialAuthenticator);
}
}
}
// if (isset($firewallData['custom_authenticator'])) {
// if (\is_string($firewallData['custom_authenticator'])) {
// $authenticators[] = new AuthenticatorType($firewallData['custom_authenticator']);
//
// return $authenticators;
// }
//
// foreach ($firewallData['custom_authenticator'] as $potentialAuthenticator) {
// if (class_exists($potentialAuthenticator)) {
// $authenticators[] = new AuthenticatorType($potentialAuthenticator);
// }
// }
// }

return $authenticators;
}
Expand Down

0 comments on commit ef75722

Please sign in to comment.