finishing creating lost password template

This commit is contained in:
Manuel Raynaud
2013-09-11 17:22:23 +02:00
parent ccf35dd37c
commit 9cc3162696
5 changed files with 64 additions and 8 deletions

View File

@@ -24,11 +24,13 @@ namespace Thelia\Controller\Front;
use Thelia\Core\Event\CustomerCreateOrUpdateEvent;
use Thelia\Core\Event\CustomerLoginEvent;
use Thelia\Core\Event\LostPasswordEvent;
use Thelia\Core\Security\Authentication\CustomerUsernamePasswordFormAuthenticator;
use Thelia\Core\Security\Exception\AuthenticationException;
use Thelia\Core\Security\Exception\UsernameNotFoundException;
use Thelia\Form\CustomerCreation;
use Thelia\Form\CustomerLogin;
use Thelia\Form\CustomerLostPasswordForm;
use Thelia\Form\CustomerModification;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Model\Customer;
@@ -45,6 +47,41 @@ use Thelia\Core\Security\Exception\WrongPasswordException;
class CustomerController extends BaseFrontController
{
use \Thelia\Cart\CartTrait;
public function newPasswordAction()
{
if (! $this->getSecurityContext()->hasCustomerUser()) {
$message = false;
$passwordLost = new CustomerLostPasswordForm($this->getRequest());
try {
$form = $this->validateForm($passwordLost);
$event = new LostPasswordEvent($form->get("email")->getData());
$this->dispatch(TheliaEvents::LOST_PASSWORD, $event);
} catch (FormValidationException $e) {
$message = sprintf("Please check your input: %s", $e->getMessage());
} catch (\Exception $e) {
$message = sprintf("Sorry, an error occured: %s", $e->getMessage());
}
if ($message !== false) {
Tlog::getInstance()->error(sprintf("Error during customer creation process : %s. Exception was %s", $message, $e->getMessage()));
$passwordLost->setErrorMessage($message);
$this->getParserContext()
->addForm($passwordLost)
->setGeneralError($message)
;
}
}
}
/**
* Create a new customer.
* On success, redirect to success_url if exists, otherwise, display the same view again.