diff --git a/src/Maker/MakeResetPassword.php b/src/Maker/MakeResetPassword.php index 5af4878fc..2c109ffae 100644 --- a/src/Maker/MakeResetPassword.php +++ b/src/Maker/MakeResetPassword.php @@ -166,6 +166,8 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma 'What is the User entity that should be used with the "forgotten password" feature? (e.g. App\\Entity\\User)' ); + // @TODO - if more than 1 $providerData - ask if we should handle more than $this->userClass + $this->emailPropertyName = $interactiveSecurityHelper->guessEmailField($io, $this->userClass); $this->emailGetterMethodName = $interactiveSecurityHelper->guessEmailGetter($io, $this->userClass, $this->emailPropertyName); $this->passwordSetterMethodName = $interactiveSecurityHelper->guessPasswordSetter($io, $this->userClass); @@ -284,6 +286,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen 'problem_validate_message_or_constant' => $problemValidateMessageOrConstant, 'problem_handle_message_or_constant' => $problemHandleMessageOrConstant, 'translator_available' => $isTranslatorAvailable, + 'multiple_entities' => false, ] ); @@ -482,6 +485,14 @@ private function generateRequestEntity(Generator $generator, ClassNameDetails $r $manipulator->addUseStatementIfNecessary($userClassDetails->getFullName()); + /** + * @TODO - If Multiple Entities + * 1) $user -> `nullable: true` + * 2) add "other" user ManyToOne + * 3) __construct(User|OTHER_USER $user) { $user instanceOf User ? $this->user = $user : $this->OTHER_USER = $user } + * 4) getUser(): User|OTHER_USER + */ + $manipulator->addConstructor([ (new Param('user'))->setType($userClassDetails->getShortName())->getNode(), (new Param('expiresAt'))->setType('\DateTimeInterface')->getNode(), diff --git a/src/Resources/skeleton/resetPassword/ResetPasswordController.tpl.php b/src/Resources/skeleton/resetPassword/ResetPasswordController.tpl.php index 6af5c3591..b12d54f05 100644 --- a/src/Resources/skeleton/resetPassword/ResetPasswordController.tpl.php +++ b/src/Resources/skeleton/resetPassword/ResetPasswordController.tpl.php @@ -119,6 +119,14 @@ private function processSendingPasswordResetEmail(string $emailFormData, MailerI $user = $this->entityManager->getRepository(::class)->findOneBy([ '' => $emailFormData, ]); + + + if (null === $user) { + $user = $this->entityManager->getRepository(ANOTHER_USER::class)->findOneBy([ + 'email' => $emailFormData, + ]); + } + // Do not reveal whether a user account was found or not. if (!$user) {