作者 lyh

gx

@@ -150,7 +150,7 @@ class BaseController extends Controller @@ -150,7 +150,7 @@ class BaseController extends Controller
150 $log = config('logging.operator_log'); 150 $log = config('logging.operator_log');
151 if(isset($log) && $log['log'] == true){ 151 if(isset($log) && $log['log'] == true){
152 if(empty($log['action']) || (strpos($log['action'],$this->request->route()->getName()) === false)){ 152 if(empty($log['action']) || (strpos($log['action'],$this->request->route()->getName()) === false)){
153 - Common::set_user_log(['model'=>$this->request->route()->getName(),'remark'=>'请求的参数:param = '.json_encode($this->param),'operator_id'=>$this->uid]); 153 + Common::set_user_log(['model'=>$this->request->route()->getName(),'remark'=>'请求的参数:param = '.json_encode($this->param),'operator_id'=>$this->uid,'type'=>isset($this->user['type']) ?? 0]);
154 } 154 }
155 } 155 }
156 return true; 156 return true;
@@ -10,6 +10,7 @@ use App\Http\Logic\Bside\User\UserLogic; @@ -10,6 +10,7 @@ use App\Http\Logic\Bside\User\UserLogic;
10 use App\Http\Logic\Bside\User\UserLoginLogic; 10 use App\Http\Logic\Bside\User\UserLoginLogic;
11 use App\Models\Project\Project; 11 use App\Models\Project\Project;
12 use App\Models\Project\Project as ProjectModel; 12 use App\Models\Project\Project as ProjectModel;
  13 +use App\Models\Service\Service;
13 use App\Models\SmsLog; 14 use App\Models\SmsLog;
14 use App\Models\User\ProjectMenu as ProjectMenuModel; 15 use App\Models\User\ProjectMenu as ProjectMenuModel;
15 use App\Models\User\ProjectRole as ProjectRoleModel; 16 use App\Models\User\ProjectRole as ProjectRoleModel;
@@ -54,12 +55,17 @@ class ComController extends BaseController @@ -54,12 +55,17 @@ class ComController extends BaseController
54 */ 55 */
55 public function autologin(UserLoginLogic $logic, EncryptUtils $encrypt) 56 public function autologin(UserLoginLogic $logic, EncryptUtils $encrypt)
56 { 57 {
57 - $data = $encrypt->unlock_url($this->param['code'], 'v6.globalso.com'); 58 + $serviceSettingModel = new Service();
  59 + $info = $serviceSettingModel->read(['type'=>4]);
  60 + if($info === false){
  61 + $this->response('当前访问地址不存在',Code::USER_ERROR);
  62 + }
  63 + $data = $encrypt->unlock_url($this->param['code'], $info['values']);
58 $data = json_decode($data, true); 64 $data = json_decode($data, true);
59 - if(empty($data['project_id'])){ 65 + if(!isset($data['project_id']) || !isset($data['user_id'])){
60 $this->response('无效Code',Code::USER_ERROR); 66 $this->response('无效Code',Code::USER_ERROR);
61 } 67 }
62 - $res = $logic->autologin($data['project_id']); 68 + $res = $logic->autologin($data);
63 $this->response('请求成功',Code::SUCCESS, $res); 69 $this->response('请求成功',Code::SUCCESS, $res);
64 } 70 }
65 71
@@ -88,9 +88,16 @@ class LoginLogic extends BaseLogic @@ -88,9 +88,16 @@ class LoginLogic extends BaseLogic
88 $encrypt = new EncryptUtils(); 88 $encrypt = new EncryptUtils();
89 $data = [ 89 $data = [
90 'domain'=>$info['values'], 90 'domain'=>$info['values'],
91 - 'autologin_code' => $encrypt->lock_url(json_encode(['project_id'=>$this->param['project_id']]),'v6.globalso.com'),  
92 'remark'=>'自动登录地址和code', 91 'remark'=>'自动登录地址和code',
93 ]; 92 ];
  93 + //获取超级管理员登录
  94 + if(isset($this->param['project_id']) && !empty($this->param['project_id'])){
  95 + $data['autologin_code'] = $encrypt->lock_url(json_encode(['project_id'=>$this->param['project_id']]),$info['values']);
  96 + }
  97 + //使用用户登录
  98 + if(isset($this->param['user_id']) && !empty($this->param['user_id'])){
  99 + $data['autologin_code'] = $encrypt->lock_url(json_encode(['user_id'=>$this->param['user_id']]),$info['values']);
  100 + }
94 //获取当前超级管理员的token 101 //获取当前超级管理员的token
95 return $this->success($data); 102 return $this->success($data);
96 } 103 }
@@ -63,14 +63,20 @@ class UserLoginLogic @@ -63,14 +63,20 @@ class UserLoginLogic
63 * @author zbj 63 * @author zbj
64 * @date 2023/7/25 64 * @date 2023/7/25
65 */ 65 */
66 - public function autologin($project_id) 66 + public function autologin($data)
67 { 67 {
68 - $has_user = User::where('project_id', $project_id)->orderBy('id', 'asc')->select(['id','mobile','role_id','token','name','project_id'])->first();  
69 - if (empty($has_user->id)) {  
70 - Common::set_user_login(['user_id'=>0, 'ip'=>request()->ip(), 'project_id' => $this->param['project_id'] ?? 0,'remark' => '该项目未找到注册账号']); 68 + //项目自动登录
  69 + if(isset($data['project_id']) && !empty($data['project_id'])){
  70 + $has_user = $this->model->read(['project_id'=>$data['project_id'],'role_id'=>0]);
  71 + }
  72 + //根据特定用户自动登录
  73 + if(isset($data['user_id']) && !empty($data['user_id'])){
  74 + $has_user = $this->model->read(['id'=>$data['user_id']]);
  75 + }
  76 + if ($has_user === false) {
71 $this->fail('该项目未找到注册账号'); 77 $this->fail('该项目未找到注册账号');
72 } 78 }
73 - $info = $this->verifyRole($has_user->toArray()); 79 + $info = $this->verifyRole($has_user);
74 if(!Cache::get($info['token'])){ 80 if(!Cache::get($info['token'])){
75 //生成新token 81 //生成新token
76 $token = md5(uniqid().$info['id']); 82 $token = md5(uniqid().$info['id']);