From e207424a2d3d5da6500697350551700a17217c72 Mon Sep 17 00:00:00 2001 From: touffies Date: Wed, 23 Oct 2013 19:50:43 +0200 Subject: [PATCH] Remove login information (Password and Confirm password) Check if email doesn't exist (Exclude current user) --- .../Thelia/Form/CustomerProfilUpdateForm.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/core/lib/Thelia/Form/CustomerProfilUpdateForm.php b/core/lib/Thelia/Form/CustomerProfilUpdateForm.php index 74e888e5b..255ceb382 100755 --- a/core/lib/Thelia/Form/CustomerProfilUpdateForm.php +++ b/core/lib/Thelia/Form/CustomerProfilUpdateForm.php @@ -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";