首页 >社区问答列表 >yii2自带的User.php类(在common/model/User.php)找不到login()方法

yii2自带的User.php类(在common/model/User.php)找不到login()方法

现在的问题是这样的:

顺便问一下,yii2自带的验证密码的,加密方式是什么?可以做修改吗?

  • 大家讲道理
  • 大家讲道理    2017-04-10 15:23:121楼

    ...那个login本来就不在common\model\User.php里,另外Yii::$app->user里的这个user也不是common\model\User.php,而是yii\web\User,那么login也就找到了;

    public function login(IdentityInterface $identity, $duration = 0)
        {
            if ($this->beforeLogin($identity, false, $duration)) {
                $this->switchIdentity($identity, $duration);
                $id = $identity->getId();
                $ip = Yii::$app->getRequest()->getUserIP();
                if ($this->enableSession) {
                    $log = "User '$id' logged in from $ip with duration $duration.";
                } else {
                    $log = "User '$id' logged in from $ip. Session not enabled.";
                }
                Yii::info($log, __METHOD__);
                $this->afterLogin($identity, false, $duration);
            }
    
            return !$this->getIsGuest();
        }
    

    +0添加回复

  • 回复