Opencart客户重置密码

问题描述 投票:0回答:1

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

如何改变这个

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

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

谢谢。

php opencart opencart2.x
1个回答
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

© www.soinside.com 2019 - 2024. All rights reserved.