求教:打算改写登录逻辑,实现只用微信账号登录,获取不到登录状态是怎么回事? [ 2.0 版本 ]
想用 Yii 模版改一个 web 应用,打算改写登录逻辑,
实现只用微信账号登录,但是获取不到登录状态,不知道是怎么回事
\common\models\LoginForm
public function login()
{
if ($this->validate()) { //validate() 部分已取消密码验证规则 //['password', 'validatePassword'],
return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
}
return false;
}
\yii\web\User login
public function login(IdentityInterface $identity, $duration = 0) //因为自建的数据库 User 表当中没有相关字段,所以在 IdentityInterface 中注销了两个方法,//public function getAuthKey();//public function validateAuthKey($authKey);
{
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();
}
补充内容:
web 应用的数据库用户表
crossey 补充于 2018-04-24 16:14
设想是用微信登录,
现在正在摸索登录的流程,
注销了接口中的两个方法,
程序能跑不报错,
但是获取不到登录状态,
不知道是怎么回事
共 1 个回答
crossey
注册时间:2017-05-31
最后登录:2018-07-20
在线时长:8小时19分
最后登录:2018-07-20
在线时长:8小时19分
- 粉丝0
- 金钱10
- 威望0
- 积分90