From 92c07b02cba28bdd76bf3690592427ac040e7597 Mon Sep 17 00:00:00 2001 From: thisfro Date: Wed, 26 Jan 2022 12:47:48 +0100 Subject: [PATCH] Fix password resetting --- src/Controller/ResetPasswordController.php | 11 ++++++----- templates/reset_password/reset.html.twig | 3 +-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Controller/ResetPasswordController.php b/src/Controller/ResetPasswordController.php index fcfd24d..f6567a0 100644 --- a/src/Controller/ResetPasswordController.php +++ b/src/Controller/ResetPasswordController.php @@ -71,7 +71,7 @@ class ResetPasswordController extends AbstractController * Validates and process the reset URL that the user clicked in their email. */ #[Route('/reset/{token}', name: 'app_reset_password')] - public function reset(Request $request, UserPasswordHasherInterface $passwordHasher, string $token = null): Response + public function reset(Request $request, UserPasswordHasherInterface $passwordEncoder, string $token = null): Response { if ($token) { // We store the token in session and remove it from the URL, to avoid the URL being @@ -106,12 +106,13 @@ class ResetPasswordController extends AbstractController $this->resetPasswordHelper->removeResetRequest($token); // Encode the plain password, and set it. - $encodedPassword = $passwordHasher->encodePassword( - $user, - $form->get('plainPassword')->getData() + $user->setPassword( + $passwordEncoder->hashPassword( + $user, + $form->get('plainPassword')->getData() + ) ); - $user->setPassword($encodedPassword); $this->getDoctrine()->getManager()->flush(); // The session is cleaned up after the password has been changed. diff --git a/templates/reset_password/reset.html.twig b/templates/reset_password/reset.html.twig index 799aa10..6badfbb 100644 --- a/templates/reset_password/reset.html.twig +++ b/templates/reset_password/reset.html.twig @@ -6,7 +6,6 @@

Reset your password

{{ form_start(resetForm) }} - {{ form_row(resetForm.plainPassword) }} - + {{form_widget(resetForm)}} {{ form_end(resetForm) }} {% endblock %}