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

@@ -41,6 +41,7 @@
<forms>
<form name="thelia.customer.creation" class="Thelia\Form\CustomerCreation"/>
<form name="thelia.customer.modification" class="Thelia\Form\CustomerModification"/>
<form name="thelia.customer.lostpassword" class="Thelia\Form\CustomerLostPasswordForm"/>
<form name="thelia.customer.login" class="Thelia\Form\CustomerLogin"/>
<form name="thelia.admin.login" class="Thelia\Form\AdminLogin"/>

View File

@@ -38,11 +38,16 @@
<default key="_controller">Thelia\Controller\Front\CustomerController::logoutAction</default>
</route>
<route id="customer.password.retrieve.view" path="/password">
<route id="customer.password.retrieve.view" path="/password" methods="get">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">password</default>
</route>
<route id="customer.password.retrieve.process" path="/password" methods="post">
<default key="_controller">Thelia\Controller\Front\CustomerController::newPasswordAction</default>
<default key="_view">password</default>
</route>
<!-- end customer routes -->
<!-- customer address routes -->

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.

View File

@@ -71,6 +71,10 @@ final class TheliaEvents
*/
const CUSTOMER_UPDATEACCOUNT = "action.updateCustomer";
/**
* sent when a customer need a new password
*/
const LOST_PASSWORD = "action.lostPassword";
/**
* Sent before the logout of the administrator.
*/