Login action :

* Add account
* If user has checked "I'm a new customer", we must verify if it's a new email address.
This commit is contained in:
touffies
2013-10-14 12:25:12 +02:00
parent d58f63990a
commit 7695c19b40
4 changed files with 77 additions and 34 deletions

View File

@@ -193,31 +193,34 @@ class CustomerController extends BaseFrontController
$form = $this->validateForm($customerLoginForm, "post");
$authenticator = new CustomerUsernamePasswordFormAuthenticator($request, $customerLoginForm);
try {
$customer = $authenticator->getAuthentifiedUser();
$authenticator = new CustomerUsernamePasswordFormAuthenticator($request, $customerLoginForm);
$this->processLogin($customer);
$customer = $authenticator->getAuthentifiedUser();
$this->redirectSuccess($customerLoginForm);
$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 ($request->request->has("account")) {
$account = $request->request->get("account");
$form = $customerLoginForm->getForm();
if ($account == 0 && $form->get("email")->getData() !== null) {
$this->redirectToRoute("customer.create.view", array("email" => $form->get("email")->getData()));
}
// 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());
}
$message = sprintf("Please check your input: %s", $e->getMessage());
} 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 (\Exception $e) {
$message = sprintf("Sorry, an error occured: %s", $e->getMessage());
}