用户登录与Yii2和MongoDB

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

任何人都可以建议我如何登录与Yii2和MongoDB用户?我曾尝试下面的例子,他们表现出了同样的错误:

https://github.com/hipstercreative/yii2-user-mongo

https://github.com/sheillendra/yii2-user-mongo/tree/master

我有一个调试的功能之一,正从功能NULL$this->getUser()结果它在LoginForm.php定义

public function login()
{
    if ($this->validate()) {
          return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);

    } else {
        return false;
    }
}
mongodb login yii2
1个回答
0
投票
/**
 * Logs in a user using the provided username and password.
 *
 * @return bool whether the user is logged in successfully
 */
public function login() {
    if ($this->validate()) {
        return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
    }

    return false;
}

/**
 * Finds user by [[username]]
 *
 * @return User|null
 */
protected function getUser() {
    if ($this->_user === null) {
        $this->_user = User::find()->where(['email' => $this->emailorphone])->orWhere(['phone' => $this->emailorphone])->one();
    }

    return $this->_user;
}
© www.soinside.com 2019 - 2024. All rights reserved.