diff --git a/src/Resources/skeleton/resetPassword/ResetPasswordController.tpl.php b/src/Resources/skeleton/resetPassword/ResetPasswordController.tpl.php index 6af5c3591..7ce8c55c2 100644 --- a/src/Resources/skeleton/resetPassword/ResetPasswordController.tpl.php +++ b/src/Resources/skeleton/resetPassword/ResetPasswordController.tpl.php @@ -25,11 +25,10 @@ public function request(Request $request, MailerInterface $mailerhandleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - return $this->processSendingPasswordResetEmail( - $form->get('')->getData(), - $mailer, - $translator - ); + /** @var string $email */ + $email = $form->get('')->getData(); + + return $this->processSendingPasswordResetEmail($email, $mailer, $translator); } return $this->render('reset_password/request.html.twig', [ @@ -94,13 +93,11 @@ public function reset(Request $request, UserPasswordHasherInterface $passwordHas // A password reset token should be used only once, remove it. $this->resetPasswordHelper->removeResetRequest($token); - // Encode(hash) the plain password, and set it. - $encodedPassword = $passwordHasher->hashPassword( - $user, - $form->get('plainPassword')->getData() - ); + /** @var string $plainPassword */ + $plainPassword = $form->get('plainPassword')->getData(); - $user->($encodedPassword); + // Encode(hash) the plain password, and set it. + $user->($passwordHasher->hashPassword($user, $plainPassword)); $this->entityManager->flush(); // The session is cleaned up after the password has been changed. @@ -143,7 +140,7 @@ private function processSendingPasswordResetEmail(string $emailFormData, MailerI $email = (new TemplatedEmail()) ->from(new Address('', '')) - ->to($user->()) + ->to((string) $user->()) ->subject('Your password reset request') ->htmlTemplate('reset_password/email.html.twig') ->context([ diff --git a/tests/Maker/MakeResetPasswordTest.php b/tests/Maker/MakeResetPasswordTest.php index 7b137ceb2..32c3a615f 100644 --- a/tests/Maker/MakeResetPasswordTest.php +++ b/tests/Maker/MakeResetPasswordTest.php @@ -352,8 +352,8 @@ public function getTestDetails(): \Generator $contentResetPasswordController = file_get_contents($runner->getPath('src/Controller/ResetPasswordController.php')); $this->assertStringContainsString('$form->get(\'emailAddress\')->getData()', $contentResetPasswordController); $this->assertStringContainsString('\'emailAddress\' => $emailFormData,', $contentResetPasswordController); - $this->assertStringContainsString('$user->setMyPassword($encodedPassword);', $contentResetPasswordController); - $this->assertStringContainsString('->to($user->getEmailAddress())', $contentResetPasswordController); + $this->assertStringContainsString('$user->setMyPassword($passwordHasher->hashPassword($user, $plainPassword));', $contentResetPasswordController); + $this->assertStringContainsString('->to((string) $user->getEmailAddress())', $contentResetPasswordController); // check ResetPasswordRequest $contentResetPasswordRequest = file_get_contents($runner->getPath('src/Entity/ResetPasswordRequest.php'));