作者 lyh

gx自动登录类型

@@ -297,7 +297,7 @@ class LoginController extends BaseController @@ -297,7 +297,7 @@ class LoginController extends BaseController
297 ]; 297 ];
298 } 298 }
299 } 299 }
300 - $info = $logic->autologin($data); 300 + $info = $logic->autologin($data,User::LOGIN_OTHER_SOURCE);
301 $this->response('success',Code::SUCCESS,['info'=>$info]); 301 $this->response('success',Code::SUCCESS,['info'=>$info]);
302 } 302 }
303 303
@@ -107,7 +107,7 @@ class UserLoginLogic @@ -107,7 +107,7 @@ class UserLoginLogic
107 * @method :post 107 * @method :post
108 * @time :2023/9/18 11:00 108 * @time :2023/9/18 11:00
109 */ 109 */
110 - public function autologin($data) 110 + public function autologin($data,$login_source = User::LOGIN_AUTO_SOURCE)
111 { 111 {
112 //项目自动登录 112 //项目自动登录
113 if(isset($data['project_id']) && !empty($data['project_id'])){ 113 if(isset($data['project_id']) && !empty($data['project_id'])){
@@ -120,7 +120,7 @@ class UserLoginLogic @@ -120,7 +120,7 @@ class UserLoginLogic
120 if ($has_user === false) { 120 if ($has_user === false) {
121 $this->fail('该项目未找到注册账号'); 121 $this->fail('该项目未找到注册账号');
122 } 122 }
123 - $info = $this->autoAssembleParam($has_user); 123 + $info = $this->autoAssembleParam($has_user,$login_source);
124 //生成新token 124 //生成新token
125 $token = md5(uniqid().$info['id']); 125 $token = md5(uniqid().$info['id']);
126 //存储缓存 126 //存储缓存
@@ -160,7 +160,7 @@ class UserLoginLogic @@ -160,7 +160,7 @@ class UserLoginLogic
160 * @method :post 160 * @method :post
161 * @time :2023/6/12 15:34 161 * @time :2023/6/12 15:34
162 */ 162 */
163 - public function autoAssembleParam($info){ 163 + public function autoAssembleParam($info,$login_source = User::LOGIN_AUTO_SOURCE){
164 $project = $this->getProjectInfo($info['project_id']); 164 $project = $this->getProjectInfo($info['project_id']);
165 if($project['site_status'] != 0){//关闭站点 165 if($project['site_status'] != 0){//关闭站点
166 $this->fail('当前网站已过期,请联系管理员及时续费。'); 166 $this->fail('当前网站已过期,请联系管理员及时续费。');
@@ -206,7 +206,7 @@ class UserLoginLogic @@ -206,7 +206,7 @@ class UserLoginLogic
206 $is_amp = $amp_info ? $amp_info['amp_status'] : 0; 206 $is_amp = $amp_info ? $amp_info['amp_status'] : 0;
207 } 207 }
208 $info['is_amp'] = $is_amp; 208 $info['is_amp'] = $is_amp;
209 - 209 + $info['login_source'] = $login_source;
210 //保存项目缓存 210 //保存项目缓存
211 Cache::put('user-'.$info['project_id'],$project,12 * 3600); 211 Cache::put('user-'.$info['project_id'],$project,12 * 3600);
212 return $this->success($info); 212 return $this->success($info);
@@ -316,6 +316,7 @@ class UserLoginLogic @@ -316,6 +316,7 @@ class UserLoginLogic
316 $is_amp = $amp_info ? $amp_info['amp_status'] : 0; 316 $is_amp = $amp_info ? $amp_info['amp_status'] : 0;
317 } 317 }
318 $info['is_amp'] = $is_amp; 318 $info['is_amp'] = $is_amp;
  319 + $info['login_source'] = User::LOGIN_PASSWORD_SOURCE;
319 //保存项目缓存 320 //保存项目缓存
320 Cache::put('user-'.$info['project_id'],$project,12 * 3600); 321 Cache::put('user-'.$info['project_id'],$project,12 * 3600);
321 return $this->success($info); 322 return $this->success($info);
@@ -363,7 +364,7 @@ class UserLoginLogic @@ -363,7 +364,7 @@ class UserLoginLogic
363 ]; 364 ];
364 }else { 365 }else {
365 //获取项目详情 366 //获取项目详情
366 - $info = $this->autoAssembleParam($info); 367 + $info = $this->autoAssembleParam($info,User::LOGIN_PASSWORD_SOURCE);
367 if(isset($info['token']) && !empty($info['token'])){ 368 if(isset($info['token']) && !empty($info['token'])){
368 //清除上一次用户缓存 369 //清除上一次用户缓存
369 Cache::pull($info['token']); 370 Cache::pull($info['token']);
@@ -17,6 +17,9 @@ class User extends Base @@ -17,6 +17,9 @@ class User extends Base
17 //自动维护create_at创建时间 updated_at修改时间 17 //自动维护create_at创建时间 updated_at修改时间
18 public $timestamps = true; 18 public $timestamps = true;
19 19
  20 + const LOGIN_AUTO_SOURCE = 1;//自动登录
  21 + const LOGIN_PASSWORD_SOURCE = 2;//账号密码登录
  22 + const LOGIN_OTHER_SOURCE = 3;//其他平台切入
20 /** 23 /**
21 * The attributes that should be cast. 24 * The attributes that should be cast.
22 * 25 *