Added validation for the cutomer email while customer save/update process in the admin customer controller

This commit is contained in:
vishalsingh.qlo325
2024-05-06 11:11:37 +05:30
parent d5bd7198cd
commit 0d598aec90

View File

@@ -1051,19 +1051,23 @@ 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;
}
@@ -1077,7 +1081,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;
}