88use Doctrine \ORM \EntityManagerInterface ;
99use Symfony \Bridge \Twig \Mime \TemplatedEmail ;
1010use Symfony \Bundle \FrameworkBundle \Controller \AbstractController ;
11- use Symfony \Component \HttpFoundation \RedirectResponse ;
1211use Symfony \Component \HttpFoundation \Request ;
1312use Symfony \Component \HttpFoundation \Response ;
1413use Symfony \Component \Mailer \MailerInterface ;
@@ -36,7 +35,9 @@ public function request(Request $request): Response
3635 $ form ->handleRequest ($ request );
3736
3837 if ($ form ->isSubmitted () && $ form ->isValid ()) {
39- return $ this ->processSendingPasswordResetEmail ($ form ->get ('email ' )->getData ());
38+ $ this ->sendPasswordResetEmail ($ form ->get ('email ' )->getData ());
39+
40+ return $ this ->redirectToRoute ('dashboard_reset_password_sent ' );
4041 }
4142
4243 return $ this ->render ('dashboard/reset_password/request.html.twig ' , [
@@ -102,7 +103,7 @@ public function passwordReset(Request $request, ?string $token = null): Response
102103 ]);
103104 }
104105
105- private function processSendingPasswordResetEmail (string $ email ): RedirectResponse
106+ private function sendPasswordResetEmail (string $ email ): void
106107 {
107108 $ user = $ this ->entityManager ->getRepository (User::class)->findOneBy ([
108109 'email ' => $ email ,
@@ -124,10 +125,9 @@ private function processSendingPasswordResetEmail(string $email): RedirectRespon
124125 $ this ->mailer ->send ($ email );
125126
126127 $ this ->setTokenObjectInSession ($ resetToken );
127- } catch (ResetPasswordExceptionInterface $ exception ) {
128+ } catch (ResetPasswordExceptionInterface ) {
129+ // Ignore errors generated by ResetPasswordHelper because it's likely caused by throttling.
128130 }
129131 }
130-
131- return $ this ->redirectToRoute ('dashboard_reset_password_sent ' );
132132 }
133133}
0 commit comments