Skip to content

Commit ba1ec16

Browse files
committed
Only update password if email sending was a success - respond with 503 is service unavailable to send email
1 parent 211b45b commit ba1ec16

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/Action/User/PasswordRequestAction.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@ public function __invoke(Request $request, string $username)
4848
}
4949

5050
if (!$user) {
51-
return new Response(null, Response::HTTP_BAD_REQUEST);
51+
return new Response(null, Response::HTTP_OK);
5252
}
5353

5454
$this->entityManager->flush();
5555
$passwordResetSuccess = $this->mailer->sendPasswordResetEmail($user);
56-
$user->setPasswordRequestedAt(new \DateTime());
57-
$this->entityManager->flush();
56+
if ($passwordResetSuccess) {
57+
$user->setPasswordRequestedAt(new \DateTime());
58+
$this->entityManager->flush();
59+
}
5860

5961
$response = new Response(null, $passwordResetSuccess ? Response::HTTP_OK : Response::HTTP_SERVICE_UNAVAILABLE);
6062
$response->setCache([

0 commit comments

Comments
 (0)