Remove login information (Password and Confirm password)

Check if email doesn't exist (Exclude current user)
This commit is contained in:
touffies
2013-10-23 19:50:43 +02:00
parent 2defbb3b6c
commit e207424a2d

View File

@@ -23,6 +23,8 @@
namespace Thelia\Form;
use Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\ExecutionContextInterface;
use Thelia\Model\Base\CustomerQuery;
use Thelia\Model\ConfigQuery;
use Thelia\Core\Translation\Translator;
@@ -51,6 +53,9 @@ class CustomerProfilUpdateForm extends CustomerCreateForm
->remove("city")
->remove("zipcode")
->remove("country")
// Remove Login Information
->remove("password")
->remove("password_confirm")
// Remove Terms & conditions
->remove("agreed")
@@ -64,6 +69,20 @@ class CustomerProfilUpdateForm extends CustomerCreateForm
));
}
/**
* @param $value
* @param ExecutionContextInterface $context
*/
public function verifyExistingEmail($value, ExecutionContextInterface $context)
{
$customer = CustomerQuery::create()->findOneByEmail($value);
// If there is already a customer for this email address and if the customer is different from the current user, do a violation
if ($customer && $customer->getId() != $this->getRequest()->getSession()->getCustomerUser()->getId()) {
$context->addViolation("This email already exists.");
}
}
public function getName()
{
return "thelia_customer_profil_update";