Add new method updatePasswordAction (Not finished)
This commit is contained in:
@@ -76,7 +76,7 @@
|
||||
|
||||
|
||||
<route id="customer.password.change.process" path="/account/password" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Front\CustomerController::newPasswordAction</default>
|
||||
<default key="_controller">Thelia\Controller\Front\CustomerController::updatePasswordAction</default>
|
||||
<default key="_view">account-password</default>
|
||||
</route>
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ use Thelia\Core\Security\Exception\UsernameNotFoundException;
|
||||
use Thelia\Form\CustomerCreateForm;
|
||||
use Thelia\Form\CustomerLogin;
|
||||
use Thelia\Form\CustomerLostPasswordForm;
|
||||
use Thelia\Form\CustomerPasswordUpdateForm;
|
||||
use Thelia\Form\CustomerUpdateForm;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Model\Customer;
|
||||
@@ -49,6 +50,7 @@ class CustomerController extends BaseFrontController
|
||||
{
|
||||
use \Thelia\Cart\CartTrait;
|
||||
|
||||
|
||||
public function newPasswordAction()
|
||||
{
|
||||
if (! $this->getSecurityContext()->hasCustomerUser()) {
|
||||
@@ -158,6 +160,44 @@ class CustomerController extends BaseFrontController
|
||||
$this->getParserContext()->addForm($customerUpdateForm);
|
||||
}
|
||||
|
||||
|
||||
public function updatePasswordAction()
|
||||
{
|
||||
if ($this->getSecurityContext()->hasCustomerUser()) {
|
||||
$message = false;
|
||||
|
||||
$customerPasswordUpdateForm = new CustomerPasswordUpdateForm($this->getRequest());
|
||||
|
||||
try {
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
|
||||
$form = $this->validateForm($customerPasswordUpdateForm, "post");
|
||||
|
||||
$customerChangeEvent = $this->createEventInstance($form->getData());
|
||||
$customerChangeEvent->setCustomer($customer);
|
||||
//$this->dispatch(TheliaEvents::CUSTOMER_UPDATEACCOUNT, $customerChangeEvent);
|
||||
|
||||
$this->redirectSuccess($customerPasswordUpdateForm);
|
||||
|
||||
} 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 password modification process : %s.", $message));
|
||||
|
||||
$customerPasswordUpdateForm->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($customerPasswordUpdateForm)
|
||||
->setGeneralError($message)
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function updateAction()
|
||||
{
|
||||
if ($this->getSecurityContext()->hasCustomerUser()) {
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\Constraints\Email;
|
||||
|
||||
@@ -25,7 +25,6 @@ namespace Thelia\Form;
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\CustomerQuery;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
/**
|
||||
@@ -80,7 +79,7 @@ class CustomerPasswordUpdateForm extends BaseForm
|
||||
|
||||
public function verifyCurrentPasswordField($value, ExecutionContextInterface $context)
|
||||
{
|
||||
|
||||
// Check current password
|
||||
}
|
||||
|
||||
public function verifyPasswordField($value, ExecutionContextInterface $context)
|
||||
@@ -88,7 +87,7 @@ class CustomerPasswordUpdateForm extends BaseForm
|
||||
$data = $context->getRoot()->getData();
|
||||
|
||||
if ($data["password"] != $data["password_confirm"]) {
|
||||
$context->addViolation("password confirmation is not the same as password field.");
|
||||
$context->addViolation("Password confirmation is not the same as password field.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user