ecshop让用户名和email都可以登陆!

2016-09-07 22:03 来源:www.chinab4c.com 作者:ecshop专家

email登陆,好处很明显.
1:可以促使用户填写真实的email.
2:不易忘记.

下面的改动,可以使ecshop用email,用户名都可以完成登陆.
---------------------------分割线-----------------------------
改动版本: ecshop 2.7.0
改动程序: /includes/modules/integrates/integrate.php
改动代码:145--162行的用户登陆函数.如下

 

    function login($username, $password)

    {

        if ($this->check_user($username, $password) > 0)

        {

            if ($this->need_sync)

            {

                $this->sync($username,$password);

            }

            $this->set_session($username);

            $this->set_cookie($username);

 

            return true;

        }

        else

        {

            return false;

        }

    }

 

 

 

改为:

 

 

 

    function login($username, $password)

    {

        if(is_email($username))
        {
                $sql = "select ".$this->field_name." from ".$this->table($this->user_table)." where ".$this->field_email."='".$username."'";
                $username = $this->db->getOne($sql);
                if(!$username) return false;
                //echo $sql;exit;
        }
        if ($this->check_user($username, $password) > 0)

        {

            if ($this->need_sync)

            {

                $this->sync($username,$password);

            }

            $this->set_session($username);

            $this->set_cookie($username);

 

            return true;

        }

        else

        {

            return false;

        }

    }

(责任编辑:chinab4c)