...
|
...
|
@@ -121,6 +121,7 @@ class User extends Api |
|
|
public function miniLogin()
|
|
|
{
|
|
|
$code = $this->request->request('code');
|
|
|
$mobile = $this->request->request('mobile');
|
|
|
if (!$code) {
|
|
|
$this->error(__('Invalid code'));
|
|
|
}
|
...
|
...
|
@@ -134,13 +135,22 @@ class User extends Api |
|
|
|
|
|
$openid = $session['openid'];
|
|
|
|
|
|
if(isset($mobile)){
|
|
|
$user = new \app\admin\model\User;
|
|
|
$user->save(['openid'=>$openid],['mobile'=>$mobile,'openid'=>null]);
|
|
|
}
|
|
|
|
|
|
$user = new \app\admin\model\User;
|
|
|
$user = $user->where(['openid'=>$openid,'is_default'=>true])->find();
|
|
|
if ($user) {
|
|
|
//如果已经有账号则直接登录
|
|
|
$ret = $this->auth->direct($user->id);
|
|
|
} else {
|
|
|
$ret = $this->register($openid);
|
|
|
$user = new \app\admin\model\User;
|
|
|
$user = $user->where(['openid'=>$openid])->find();
|
|
|
if(empty($user)){
|
|
|
$ret = $this->register($openid);
|
|
|
}
|
|
|
}
|
|
|
if (!$ret) {
|
|
|
$this->error($this->auth->getError());
|
...
|
...
|
|