Opencart客户重置密码

时间:2016-02-03 09:58:19

标签: php opencart opencart2.x

Open-cart 版本2.1.0.2中,当客户点击忘记密码链接并输入他/她的电子邮件时,系统会将新密码发送到他们的电子邮件地址。

如何将其更改为

当客户点击忘记密码链接并输入他/她的电子邮件时,会将一个链接发送到他们的电子邮件地址,他们可以点击该链接并在那里更改密码吗?

我想出了管理密码重置的方式是我想要的方式,但不知道如何实现它。有什么想法吗?

谢谢。

1 个答案:

答案 0 :(得分:0)

您需要在以下扩展程序中进行一些修改。

http://www.opencart.com/index.php?route=extension/extension/info&extension_id=25484&filter_search=password&filter_license=0

之后它会正常工作。

更改位于 vqmod/xml/customer_reset_pwd_link.ocmod.xml 文件中。

使用以下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>

注意:使用ocmod