From 6f9d5bccc47f9e315b5e7365f6cae5c4814353d2 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Wed, 12 Jun 2024 18:55:28 +0530 Subject: [PATCH 1/2] Fixed: Admin was able to create account using 0 as email --- .../admin/AdminCustomersController.php | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/controllers/admin/AdminCustomersController.php b/controllers/admin/AdminCustomersController.php index 6c763f10c..c5c49544e 100644 --- a/controllers/admin/AdminCustomersController.php +++ b/controllers/admin/AdminCustomersController.php @@ -1044,22 +1044,27 @@ class AdminCustomersControllerCore extends AdminController $customer = new Customer(); if (Validate::isEmail($customer_email)) { $customer->getByEmail($customer_email); - } - if ($customer->id) { - $this->errors[] = Tools::displayError('An account already exists for this email address:').' '.$customer_email; + if ($customer->id) { + $this->errors[] = Tools::displayError('An account already exists for this email address:').' '.$customer_email; + $this->display = 'edit'; + return $customer; + } elseif (trim(Tools::getValue('passwd')) == '') { + $this->validateRules(); + $this->errors[] = Tools::displayError('Password can not be empty.'); + $this->display = 'edit'; + } elseif ($customer = parent::processAdd()) { + $this->context->smarty->assign('new_customer', $customer); + return $customer; + } + } else { + $this->errors[] = Tools::displayError('Invalid email address.'); $this->display = 'edit'; - return $customer; - } elseif (trim(Tools::getValue('passwd')) == '') { - $this->validateRules(); - $this->errors[] = Tools::displayError('Password can not be empty.'); - $this->display = 'edit'; - } elseif ($customer = parent::processAdd()) { - $this->context->smarty->assign('new_customer', $customer); - return $customer; } + return false; } + public function processUpdate() { if (Validate::isLoadedObject($this->object)) { @@ -1070,7 +1075,11 @@ class AdminCustomersControllerCore extends AdminController $customer = new Customer(); if (Validate::isEmail($customer_email)) { $customer->getByEmail($customer_email); + } else { + $this->errors[] = Tools::displayError('Invalid email address.'); + $this->display = 'edit'; } + if (($customer->id) && ($customer->id != (int)$this->object->id)) { $this->errors[] = Tools::displayError('An account already exists for this email address:').' '.$customer_email; } From 08a0f9fd3bc8ffb907ffb380055f9c5b5cf8ab8f Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Thu, 4 Jul 2024 11:29:26 +0530 Subject: [PATCH 2/2] Removed non required code --- controllers/admin/AdminCustomersController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/controllers/admin/AdminCustomersController.php b/controllers/admin/AdminCustomersController.php index 93fc9ed6b..008ef64c6 100644 --- a/controllers/admin/AdminCustomersController.php +++ b/controllers/admin/AdminCustomersController.php @@ -1077,7 +1077,6 @@ class AdminCustomersControllerCore extends AdminController $customer->getByEmail($customer_email); } else { $this->errors[] = Tools::displayError('Invalid email address.'); - $this->display = 'edit'; } if (($customer->id) && ($customer->id != (int)$this->object->id)) {