作者 xwp

登录逻辑修改

... ... @@ -153,19 +153,18 @@ class User extends Api
$user = $user->where(['openid'=>$openid,'is_default'=>true])->find();
if ($user) {
//如果已经有账号则直接登录
$ret = $this->auth->direct($user->id);
$this->auth->direct($user->id);
$return['user_info'] = $this->auth->getUserinfo();
} else {
$user = new \app\admin\model\User;
$user = $user->where(['openid'=>$openid])->find();
if(empty($user)){
$ret = $this->register($openid,empty($mobile)?'':$mobile);
if(!empty($mobile)){
$this->register($openid,empty($mobile)?'':$mobile);
$return['user_info'] = $this->auth->getUserinfo();
}else{
$return['user_info'] = [];
}
}
if (!$ret) {
$this->error($this->auth->getError());
}
$return['user_info'] = $this->auth->getUserinfo();
$return['session'] = $session;
$this->success('Logged in successful', $return);
... ...