Skip to content

Commit

Permalink
Rollback ResetController
Browse files Browse the repository at this point in the history
  • Loading branch information
Florent Chaintreuil committed Apr 5, 2019
1 parent f83bfd4 commit c0939ee
Showing 1 changed file with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,23 @@ class ResetController extends Controller
* @Layout()
* @Route("/reset-request", name="oro_customer_frontend_customer_user_reset_request")
* @Method({"GET", "POST"})
* @param Request $request
* @return array|RedirectResponse
*/
public function requestAction(Request $request)
public function requestAction()
{
if ($this->getUser()) {
return $this->redirectToRoute('oro_customer_frontend_customer_user_profile');
return $this->redirect($this->generateUrl('oro_customer_frontend_customer_user_profile'));
}

/** @var CustomerUserPasswordRequestHandler $handler */
$handler = $this->get('oro_customer.customer_user.password_request.handler');
$form = $this->get('oro_customer.provider.frontend_customer_user_form')
->getForgotPasswordForm();

$request = $this->get('request_stack')->getCurrentRequest();
$email = $handler->process($form, $request);
if ($email) {
$this->get('session')->set(static::SESSION_EMAIL, $this->getObfuscatedEmail($email));
return $this->redirectToRoute('oro_customer_frontend_customer_user_reset_check_email');
return $this->redirect($this->generateUrl('oro_customer_frontend_customer_user_reset_check_email'));
}

return [];
Expand All @@ -57,18 +56,16 @@ public function requestAction(Request $request)
* @Layout()
* @Route("/check-email", name="oro_customer_frontend_customer_user_reset_check_email")
* @Method({"GET"})
* @param Request $request
* @return array|RedirectResponse
*/
public function checkEmailAction(Request $request)
public function checkEmailAction()
{
$session = $this->get('session');
$email = $session->get(static::SESSION_EMAIL);
$session->remove(static::SESSION_EMAIL);

if (empty($email)) {
// the user does not come from the sendEmail action
return $this->redirectToRoute('oro_customer_frontend_customer_user_reset_request');
return $this->redirect($this->generateUrl('oro_customer_frontend_customer_user_reset_request'));
}

return [
Expand Down Expand Up @@ -103,14 +100,14 @@ public function resetAction(Request $request)
}

$session = $this->get('session');
$ttl = $this->getParameter('oro_user.reset.ttl');
$ttl = $this->container->getParameter('oro_user.reset.ttl');
if (!$user->isPasswordRequestNonExpired($ttl)) {
$this->addFlash(
$session->getFlashBag()->add(
'warn',
'oro.customer.customeruser.profile.password.reset.ttl_expired.message'
);

return $this->redirectToRoute('oro_customer_frontend_customer_user_reset_request');
return $this->redirect($this->generateUrl('oro_customer_frontend_customer_user_reset_request'));
}

/** @var CustomerUserPasswordResetHandler $handler */
Expand All @@ -124,15 +121,15 @@ public function resetAction(Request $request)
$session->invalidate();
$this->get('security.token_storage')->setToken(null);

$this->addFlash(
$session->getFlashBag()->add(
'success',
'oro.customer.customeruser.profile.password_reset.message'
);

if ($actionParameter) {
$response = $this->get('oro_ui.router')->redirect($user);
} else {
$response = $this->redirectToRoute('oro_customer_customer_user_security_login');
$response = $this->redirect($this->generateUrl('oro_customer_customer_user_security_login'));
}

return $response;
Expand Down

0 comments on commit c0939ee

Please sign in to comment.