From 1a8dfa46f44937cbcd4c46b69c2fc31dd9c85c04 Mon Sep 17 00:00:00 2001 From: touffies Date: Wed, 16 Oct 2013 10:55:23 +0200 Subject: [PATCH] Redirect new customer with valid email to the registration page. --- .../Controller/Front/CustomerController.php | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/core/lib/Thelia/Controller/Front/CustomerController.php b/core/lib/Thelia/Controller/Front/CustomerController.php index bf84d987f..013de8ada 100755 --- a/core/lib/Thelia/Controller/Front/CustomerController.php +++ b/core/lib/Thelia/Controller/Front/CustomerController.php @@ -193,34 +193,33 @@ class CustomerController extends BaseFrontController $form = $this->validateForm($customerLoginForm, "post"); - try { - - $authenticator = new CustomerUsernamePasswordFormAuthenticator($request, $customerLoginForm); - - $customer = $authenticator->getAuthentifiedUser(); - - $this->processLogin($customer); - - $this->redirectSuccess($customerLoginForm); - - } catch (UsernameNotFoundException $e) { - $message = "1.Wrong email or password. Please try again"; - } catch (WrongPasswordException $e) { - $message = "2.Wrong email or password. Please try again"; - } catch (AuthenticationException $e) { - $message = "3.Wrong email or password. Please try again"; - } - - } catch (FormValidationException $e) { - // If User is a new customer - $form = $customerLoginForm->getForm(); if ($form->get('account')->getData() == 0 && !$form->get("email")->getErrors()) { $this->redirectToRoute("customer.create.view", array("email" => $form->get("email")->getData())); } else { - $message = sprintf("Please check your input: %s", $e->getMessage()); + + try { + + $authenticator = new CustomerUsernamePasswordFormAuthenticator($request, $customerLoginForm); + + $customer = $authenticator->getAuthentifiedUser(); + + $this->processLogin($customer); + + $this->redirectSuccess($customerLoginForm); + + } catch (UsernameNotFoundException $e) { + $message = "Wrong email or password. Please try again"; + } catch (WrongPasswordException $e) { + $message = "Wrong email or password. Please try again"; + } catch (AuthenticationException $e) { + $message = "Wrong email or password. Please try again"; + } + } + } catch (FormValidationException $e) { + $message = sprintf("Please check your input: %s", $e->getMessage()); } catch (\Exception $e) { $message = sprintf("Sorry, an error occured: %s", $e->getMessage()); }