[-] FO : you cannot reset the password of a deactivated account anymore #PSCFV-5621

This commit is contained in:
dMetzger
2012-11-15 08:14:03 +00:00
parent 8db53b4b2c
commit 98bf8f93fc
+25 -28
View File
@@ -45,38 +45,37 @@ class PasswordControllerCore extends FrontController
$customer->getByemail($email);
if (!Validate::isLoadedObject($customer))
$this->errors[] = Tools::displayError('There is no account registered to this e-mail address.');
elseif (!$customer->active)
$this->errors[] = Tools::displayError('You cannot regenerate the password for this account.');
elseif ((strtotime($customer->last_passwd_gen.'+'.(int)($min_time = Configuration::get('PS_PASSWD_TIME_FRONT')).' minutes') - time()) > 0)
$this->errors[] = sprintf(Tools::displayError('You can regenerate your password only every %d minute(s)'), (int)$min_time);
else
{
if ((strtotime($customer->last_passwd_gen.'+'.(int)($min_time = Configuration::get('PS_PASSWD_TIME_FRONT')).' minutes') - time()) > 0)
$this->errors[] = sprintf(
Tools::displayError('You can regenerate your password only every %d minute(s)'),
(int)$min_time
);
$mail_params = array(
'{email}' => $customer->email,
'{lastname}' => $customer->lastname,
'{firstname}' => $customer->firstname,
'{url}' => $this->context->link->getPageLink('password', true, null, 'token='.$customer->secure_key.'&id_customer='.(int)$customer->id)
);
if (Mail::Send($this->context->language->id, 'password_query', Mail::l('Password query confirmation'), $mail_params, $customer->email, $customer->firstname.' '.$customer->lastname))
$this->context->smarty->assign(array('confirmation' => 2, 'email' => $customer->email));
else
{
if (Mail::Send($this->context->language->id, 'password_query', Mail::l('Password query confirmation'),
array(
'{email}' => $customer->email,
'{lastname}' => $customer->lastname,
'{firstname}' => $customer->firstname,
'{url}' => $this->context->link->getPageLink('password', true, null, 'token='.$customer->secure_key.'&id_customer='.(int)$customer->id)),
$customer->email,
$customer->firstname.' '.$customer->lastname))
$this->context->smarty->assign(array('confirmation' => 2, 'email' => $customer->email));
else
$this->errors[] = Tools::displayError('Error occurred while sending the e-mail.');
}
$this->errors[] = Tools::displayError('Error occurred while sending the e-mail.');
}
}
}
else if (($token = Tools::getValue('token')) && ($id_customer = (int)(Tools::getValue('id_customer'))))
elseif (($token = Tools::getValue('token')) && ($id_customer = (int)Tools::getValue('id_customer')))
{
$email = Db::getInstance()->getValue('SELECT `email` FROM '._DB_PREFIX_.'customer c WHERE c.`secure_key` = \''.pSQL($token).'\' AND c.id_customer='.(int)$id_customer);
$email = Db::getInstance()->getValue('SELECT `email` FROM '._DB_PREFIX_.'customer c WHERE c.`secure_key` = \''.pSQL($token).'\' AND c.id_customer = '.(int)$id_customer);
if ($email)
{
$customer = new Customer();
$customer->getByemail($email);
if ((strtotime($customer->last_passwd_gen.'+'.(int)($min_time = Configuration::get('PS_PASSWD_TIME_FRONT')).' minutes') - time()) > 0)
if (!Validate::isLoadedObject($customer))
$this->errors[] = Tools::displayError('Customer account not found');
elseif (!$customer->active)
$this->errors[] = Tools::displayError('You cannot regenerate the password for this account.');
elseif ((strtotime($customer->last_passwd_gen.'+'.(int)Configuration::get('PS_PASSWD_TIME_FRONT').' minutes') - time()) > 0)
Tools::redirect('index.php?controller=authentication&error_regen_pwd');
else
{
@@ -85,14 +84,13 @@ class PasswordControllerCore extends FrontController
if ($customer->update())
{
Hook::exec('actionPasswordRenew', array('customer' => $customer, 'password' => $password));
if (Mail::Send($this->context->language->id, 'password', Mail::l('Your new password'),
array(
$mail_params = array(
'{email}' => $customer->email,
'{lastname}' => $customer->lastname,
'{firstname}' => $customer->firstname,
'{passwd}' => $password),
$customer->email,
$customer->firstname.' '.$customer->lastname))
'{passwd}' => $password
);
if (Mail::Send($this->context->language->id, 'password', Mail::l('Your new password'), $mail_params, $customer->email, $customer->firstname.' '.$customer->lastname))
$this->context->smarty->assign(array('confirmation' => 1, 'email' => $customer->email));
else
$this->errors[] = Tools::displayError('Error occurred while sending the e-mail.');
@@ -104,7 +102,7 @@ class PasswordControllerCore extends FrontController
else
$this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted');
}
else if (($token = Tools::getValue('token')) || ($id_customer = Tools::getValue('id_customer')))
elseif (Tools::getValue('token') || Tools::getValue('id_customer'))
$this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted');
}
@@ -115,7 +113,6 @@ class PasswordControllerCore extends FrontController
public function initContent()
{
parent::initContent();
$this->setTemplate(_PS_THEME_DIR_.'password.tpl');
}
}