Skip to content

Commit 211b45b

Browse files
committed
Password reset response 503 is no email asuccess
1 parent 51b5d20 commit 211b45b

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/Action/User/PasswordRequestAction.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,16 @@ public function __invoke(Request $request, string $username)
4747
return new Response(null, Response::HTTP_UNPROCESSABLE_ENTITY);
4848
}
4949

50-
if ($user) {
51-
$this->entityManager->flush();
52-
$this->mailer->sendPasswordResetEmail($user);
53-
$user->setPasswordRequestedAt(new \DateTime());
54-
$this->entityManager->flush();
50+
if (!$user) {
51+
return new Response(null, Response::HTTP_BAD_REQUEST);
5552
}
5653

57-
$response = new Response(null, Response::HTTP_OK);
54+
$this->entityManager->flush();
55+
$passwordResetSuccess = $this->mailer->sendPasswordResetEmail($user);
56+
$user->setPasswordRequestedAt(new \DateTime());
57+
$this->entityManager->flush();
58+
59+
$response = new Response(null, $passwordResetSuccess ? Response::HTTP_OK : Response::HTTP_SERVICE_UNAVAILABLE);
5860
$response->setCache([
5961
'private' => true,
6062
's_maxage' => 0,

0 commit comments

Comments
 (0)