Fixed: admin can create new account using the baaned account email

This commit is contained in:
vishalsingh.qlo325
2024-05-29 11:56:26 +05:30
parent 19c4e45320
commit 1a4635e769
2 changed files with 92 additions and 0 deletions

View File

@@ -1049,6 +1049,9 @@ class AdminCustomersControllerCore extends AdminController
$this->errors[] = Tools::displayError('An account already exists for this email address:').' '.$customer_email;
$this->display = 'edit';
return $customer;
} elseif (trim(Customer::customerExists($customer_email, false, true))) {
$this->errors[] = Tools::displayError('The email is already associated with a banned account. Please use a different one.');
$this->display = 'edit';
} elseif (trim(Tools::getValue('passwd')) == '') {
$this->validateRules();
$this->errors[] = Tools::displayError('Password can not be empty.');
@@ -1289,4 +1292,43 @@ class AdminCustomersControllerCore extends AdminController
die('ok');
}
}
public function ajaxProcessVerifyCustomerEmail()
{
$response = array(
'status' => true
);
if ($email = Tools::getValue('email')) {
$newIdCustomer = Tools::getValue('id_customer', 0);
$oldIdCustomer = Customer::customerExists($email, true, false);
if ($oldIdCustomer) { // means that the account exists.
$objCustomer = Customer::getByEmail($email, null, false);
if (!$objCustomer // means that the customer was deleted
&& $oldIdCustomer != $newIdCustomer // the admin is trying to update another account in case the new id is not zero
) {
$response['status'] = false;
$response['msg'] = Tools::displayError('The email is already associated with a banned account. Please use a different one.');
}
}
}
$this->ajaxDie(json_encode($response));
}
public function setMedia()
{
parent::setMedia();
if ($this->loadObject(true)
&& ($this->display == 'edit' || $this->display == 'add')
) {
$idCustomer = $this->object->id ? $this->object->id : 0;
Media::addJSDef(
array(
'customer_controller_url' => self::$currentIndex.'&token='.$this->token,
'id_customer' => $idCustomer
)
);
$this->addJS(_PS_JS_DIR_.'admin/customers.js');
}
}
}