|
|
|
@ -62,12 +62,12 @@ class ResetPasswordController extends AbstractController |
|
|
|
|
public function checkEmail(): Response |
|
|
|
|
{ |
|
|
|
|
// We prevent users from directly accessing this page |
|
|
|
|
if (!$this->canCheckEmail()) { |
|
|
|
|
if (null === ($resetToken = $this->getTokenObjectFromSession())) { |
|
|
|
|
return $this->redirectToRoute('app_forgot_password_request'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $this->render('@ChamiloCore/reset_password/check_email.html.twig', [ |
|
|
|
|
'tokenLifetime' => $this->resetPasswordHelper->getTokenLifetime(), |
|
|
|
|
'resetToken' => $resetToken, |
|
|
|
|
]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -136,9 +136,6 @@ class ResetPasswordController extends AbstractController |
|
|
|
|
'email' => $emailFormData, |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
// Marks that you are allowed to see the app_check_email page. |
|
|
|
|
$this->setCanCheckEmailInSession(); |
|
|
|
|
|
|
|
|
|
// Do not reveal whether a user account was found or not. |
|
|
|
|
if (!$user) { |
|
|
|
|
return $this->redirectToRoute('app_check_email'); |
|
|
|
@ -147,27 +144,33 @@ class ResetPasswordController extends AbstractController |
|
|
|
|
try { |
|
|
|
|
$resetToken = $this->resetPasswordHelper->generateResetToken($user); |
|
|
|
|
} catch (ResetPasswordExceptionInterface $e) { |
|
|
|
|
$this->addFlash('reset_password_error', sprintf( |
|
|
|
|
'There was a problem handling your password reset request - %s', |
|
|
|
|
$e->getReason() |
|
|
|
|
)); |
|
|
|
|
// If you want to tell the user why a reset email was not sent, uncomment |
|
|
|
|
// the lines below and change the redirect to 'app_forgot_password_request'. |
|
|
|
|
// Caution: This may reveal if a user is registered or not. |
|
|
|
|
// |
|
|
|
|
// $this->addFlash('reset_password_error', sprintf( |
|
|
|
|
// 'There was a problem handling your password reset request - %s', |
|
|
|
|
// $e->getReason() |
|
|
|
|
// )); |
|
|
|
|
|
|
|
|
|
return $this->redirectToRoute('app_forgot_password_request'); |
|
|
|
|
return $this->redirectToRoute('app_check_email'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$email = (new TemplatedEmail()) |
|
|
|
|
->from(new Address('test@test.com', 'test')) |
|
|
|
|
->from(new Address('admin@example.com', 'Admin')) |
|
|
|
|
->to($user->getEmail()) |
|
|
|
|
->subject('Your password reset request') |
|
|
|
|
->htmlTemplate('@ChamiloCore/reset_password/email.html.twig') |
|
|
|
|
->context([ |
|
|
|
|
'resetToken' => $resetToken, |
|
|
|
|
'tokenLifetime' => $this->resetPasswordHelper->getTokenLifetime(), |
|
|
|
|
]) |
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
$mailer->send($email); |
|
|
|
|
|
|
|
|
|
// Store the token object in session for retrieval in check-email route. |
|
|
|
|
$this->setTokenObjectInSession($resetToken); |
|
|
|
|
|
|
|
|
|
return $this->redirectToRoute('app_check_email'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|