Reputation: 63
In Open-cart version 2.1.0.2 , when a customer clicks forgotten password link and enters his/her email, a new password will be sent to their email address.
How to change this to
When customers click forgotten password link and enters his/her email, a link will be sent to their email address,and they can click the link and change the password there?
I figured out the way admin password resets is the way I wanted, but do not know how exactly to implement it. Any ideas ?
Thank You.
Upvotes: 0
Views: 1923
Reputation: 760
You need to do some modification in following extension.
After that it will work fine.
Changes is in vqmod/xml/customer_reset_pwd_link.ocmod.xml
file.
check with following ocmod xml
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<id>Customer Forgottten Password Email Verification</id>
<version>1.0.0</version>
<author>Amit Maurya</author>
<code>forgotten_password</code>
<file path="catalog/controller/account/forgotten.php">
<operation>
<search><![CDATA[
$password = substr(sha1(uniqid(mt_rand(), true)), 0, 10);
]]>
</search>
<add position="replace" offset="8">
<![CDATA[
$this->model_account_customer->checkcolumn();
$code = sha1(uniqid(mt_rand(), true));
$this->model_account_customer->editCode($this->request->post['email'], $code);
$subject = sprintf($this->language->get('text_subject'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'));
$message = sprintf($this->language->get('text_greeting'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8')) . "\n\n";
$message .= $this->language->get('text_change') . "\n\n";
$message .= html_entity_decode($this->url->link('account/reset_pwd_link', 'code=' . $code, 'SSL')) . "\n\n";
$message .= sprintf($this->language->get('text_ip'), $this->request->server['REMOTE_ADDR']) . "\n\n";
]]>
</add>
</operation>
</file>
<file path="catalog/model/account/customer.php">
<operation>
<search><![CDATA[
public function editPassword($email, $password) {
]]>
</search>
<add position="before">
<![CDATA[
public function checkcolumn() {
$hasColumn= FALSE;
$result = $this->db->query( "DESCRIBE `".DB_PREFIX."customer`;" );
foreach ($result->rows as $row) {
if ($row['Field'] == 'code') {
$hasColumn = TRUE;
break;
}
}
if (!$hasColumn) {
$sql = "ALTER TABLE `".DB_PREFIX."customer` ADD `code` VARCHAR( 40 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''";
$this->db->query( $sql );
}
}
public function editCode($email, $code) {
$this->db->query("UPDATE `" . DB_PREFIX . "customer` SET code = '" . $this->db->escape($code) . "' WHERE LCASE(email) = '" . $this->db->escape(utf8_strtolower($email)) . "'");
}
public function getUserByCode($code) {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "customer` WHERE code = '" . $this->db->escape($code) . "' AND code != ''");
return $query->row;
}
]]>
</add>
</operation>
</file>
<file path="catalog/language/english/mail/forgotten.php">
<operation>
<search><![CDATA[
$_['text_subject'] = '%s - New Password';
]]>
</search>
<add position="replace" offset="3"><![CDATA[
$_['text_subject'] = '%s - Password reset request';
$_['text_greeting'] = 'A new password was requested for %s .';
$_['text_change'] = 'To reset your password click on the link below:';
$_['text_ip'] = 'The IP used to make this request was: %s';
]]>
</add>
</operation>
</file>
</modification>
Note : use ocmod
Upvotes: 0