|
@@ -28,17 +28,45 @@ class UserLoginLogic |
|
@@ -28,17 +28,45 @@ class UserLoginLogic |
|
28
|
}
|
28
|
}
|
|
29
|
|
29
|
|
|
30
|
/**
|
30
|
/**
|
|
31
|
- * @remark :登录接口
|
31
|
+ * @remark :(登录)
|
|
|
|
32
|
+ * @name :verifyAccountPassword
|
|
|
|
33
|
+ * @author :lyh
|
|
|
|
34
|
+ * @method :post
|
|
|
|
35
|
+ * @time :2023/8/29 14:50
|
|
|
|
36
|
+ */
|
|
|
|
37
|
+ public function login(){
|
|
|
|
38
|
+ //先验证手机号是否在项目中存在
|
|
|
|
39
|
+ $info = $this->model->read(['mobile'=>$this->param['mobile'],'status'=>$this->model::STATUS_ZERO],['id']);
|
|
|
|
40
|
+ if($info === false){
|
|
|
|
41
|
+ $this->fail('当前用户不存在或者被禁用',Code::USER_REGISTER_ERROE);
|
|
|
|
42
|
+ }
|
|
|
|
43
|
+
|
|
|
|
44
|
+ //查看当前账号下有几个项目
|
|
|
|
45
|
+ $list = $this->model->list(['mobile'=>$this->param['mobile'],
|
|
|
|
46
|
+ 'password'=>$this->param['password'],'status'=>$this->model::STATUS_ZERO],'id',['id','project_id']);
|
|
|
|
47
|
+ if(empty($list)){
|
|
|
|
48
|
+ //验证code
|
|
|
|
49
|
+ $list = $this->verifyCode($this->param['mobile'],$this->param['password']);
|
|
|
|
50
|
+ }
|
|
|
|
51
|
+ //获取所有项目的项目id
|
|
|
|
52
|
+ foreach ($list as $v){
|
|
|
|
53
|
+ $projectArr[] = $v['project_id'];
|
|
|
|
54
|
+ }
|
|
|
|
55
|
+ $projectModel = new Project();
|
|
|
|
56
|
+ $project_list = $projectModel->list(['id'=>['in',$projectArr]],'id',['id','title']);
|
|
|
|
57
|
+ return $this->success($project_list);
|
|
|
|
58
|
+ }
|
|
|
|
59
|
+
|
|
|
|
60
|
+ /**
|
|
|
|
61
|
+ * @remark :根据选择的项目登录
|
|
32
|
* @name :login
|
62
|
* @name :login
|
|
33
|
* @author :lyh
|
63
|
* @author :lyh
|
|
34
|
* @method :post
|
64
|
* @method :post
|
|
35
|
* @time :2023/6/17 16:43
|
65
|
* @time :2023/6/17 16:43
|
|
36
|
*/
|
66
|
*/
|
|
37
|
- public function login(){
|
|
|
|
38
|
- //验证账号密码是否正确
|
|
|
|
39
|
- $info = $this->verifyAccount();
|
|
|
|
40
|
- //验证角色是否被禁用+获取项目详情
|
|
|
|
41
|
- $info = $this->verifyRole($info);
|
67
|
+ public function projectLogin(){
|
|
|
|
68
|
+ //获取项目详情
|
|
|
|
69
|
+ $info = $this->assembleParam($this->param['mobile'],$this->param['project_id']);
|
|
42
|
if(isset($info['token']) && !empty($info['token'])){
|
70
|
if(isset($info['token']) && !empty($info['token'])){
|
|
43
|
//清除上一次用户缓存
|
71
|
//清除上一次用户缓存
|
|
44
|
Cache::pull($info['token']);
|
72
|
Cache::pull($info['token']);
|
|
@@ -58,6 +86,7 @@ class UserLoginLogic |
|
@@ -58,6 +86,7 @@ class UserLoginLogic |
|
58
|
return $this->success($info);
|
86
|
return $this->success($info);
|
|
59
|
}
|
87
|
}
|
|
60
|
|
88
|
|
|
|
|
89
|
+
|
|
61
|
/**
|
90
|
/**
|
|
62
|
* 自动登录
|
91
|
* 自动登录
|
|
63
|
* @author zbj
|
92
|
* @author zbj
|
|
@@ -71,12 +100,12 @@ class UserLoginLogic |
|
@@ -71,12 +100,12 @@ class UserLoginLogic |
|
71
|
}
|
100
|
}
|
|
72
|
//根据特定用户自动登录
|
101
|
//根据特定用户自动登录
|
|
73
|
if(isset($data['user_id']) && !empty($data['user_id'])){
|
102
|
if(isset($data['user_id']) && !empty($data['user_id'])){
|
|
74
|
- $has_user = $this->model->read(['id'=>$data['user_id']]);
|
103
|
+ $has_user = $this->model->read(['id'=>$data['user_id'],'status'=>$this->model::STATUS_ZERO]);
|
|
75
|
}
|
104
|
}
|
|
76
|
if ($has_user === false) {
|
105
|
if ($has_user === false) {
|
|
77
|
$this->fail('该项目未找到注册账号');
|
106
|
$this->fail('该项目未找到注册账号');
|
|
78
|
}
|
107
|
}
|
|
79
|
- $info = $this->verifyRole($has_user);
|
108
|
+ $info = $this->autoAssembleParam($has_user);
|
|
80
|
if(!Cache::get($info['token'])){
|
109
|
if(!Cache::get($info['token'])){
|
|
81
|
//生成新token
|
110
|
//生成新token
|
|
82
|
$token = md5(uniqid().$info['id']);
|
111
|
$token = md5(uniqid().$info['id']);
|
|
@@ -91,29 +120,6 @@ class UserLoginLogic |
|
@@ -91,29 +120,6 @@ class UserLoginLogic |
|
91
|
}
|
120
|
}
|
|
92
|
|
121
|
|
|
93
|
/**
|
122
|
/**
|
|
94
|
- * @name :(验证账号、密码或验证码是否正确)verifyAccount
|
|
|
|
95
|
- * @author :lyh
|
|
|
|
96
|
- * @method :post
|
|
|
|
97
|
- * @time :2023/6/12 15:31
|
|
|
|
98
|
- */
|
|
|
|
99
|
- public function verifyAccount(){
|
|
|
|
100
|
- $info = $this->model->read(['mobile'=>$this->param['mobile']],['id','mobile','status','password','role_id','wechat','token','name','project_id']);
|
|
|
|
101
|
- if($info === false){
|
|
|
|
102
|
- $this->fail('当前用户不存在',Code::USER_REGISTER_ERROE);
|
|
|
|
103
|
- }
|
|
|
|
104
|
- if($info['status'] != self::USER_STATUS){
|
|
|
|
105
|
- $this->fail('当前用户被禁用',Code::USER_REGISTER_ERROE);
|
|
|
|
106
|
- }
|
|
|
|
107
|
- //密码加密
|
|
|
|
108
|
- $password = base64_encode(md5($this->param['password']));
|
|
|
|
109
|
- if($password != $info['password']){
|
|
|
|
110
|
- $this->verifyCode($this->param['mobile'],$this->param['password']);
|
|
|
|
111
|
- }
|
|
|
|
112
|
- unset($info['password']);
|
|
|
|
113
|
- return $this->success($info);
|
|
|
|
114
|
- }
|
|
|
|
115
|
-
|
|
|
|
116
|
- /**
|
|
|
|
117
|
* @remark :验证验证码是否正确或是否过期
|
123
|
* @remark :验证验证码是否正确或是否过期
|
|
118
|
* @name :verifyCode
|
124
|
* @name :verifyCode
|
|
119
|
* @author :lyh
|
125
|
* @author :lyh
|
|
@@ -131,24 +137,17 @@ class UserLoginLogic |
|
@@ -131,24 +137,17 @@ class UserLoginLogic |
|
131
|
}else{
|
137
|
}else{
|
|
132
|
$this->fail('账号密码错误/验证码错误',Code::USER_REGISTER_ERROE);
|
138
|
$this->fail('账号密码错误/验证码错误',Code::USER_REGISTER_ERROE);
|
|
133
|
}
|
139
|
}
|
|
134
|
- return true;
|
140
|
+ $list = $this->model->list(['mobile'=>$this->param['mobile'],'status'=>$this->model::STATUS_ZERO],['id','project_id']);
|
|
|
|
141
|
+ return $this->success($list);
|
|
135
|
}
|
142
|
}
|
|
|
|
143
|
+
|
|
136
|
/**
|
144
|
/**
|
|
137
|
- * @name :(验证角色是否禁用)verifyRole
|
145
|
+ * @name :自动登录组装返回数据
|
|
138
|
* @author :lyh
|
146
|
* @author :lyh
|
|
139
|
* @method :post
|
147
|
* @method :post
|
|
140
|
* @time :2023/6/12 15:34
|
148
|
* @time :2023/6/12 15:34
|
|
141
|
*/
|
149
|
*/
|
|
142
|
- public function verifyRole($info){
|
|
|
|
143
|
- //当前用户角色是否被禁用
|
|
|
|
144
|
- $projectRoleModel = new ProjectRoleModel();
|
|
|
|
145
|
- if($info['role_id'] != 0){
|
|
|
|
146
|
- $role_info = $projectRoleModel->read(['id'=>$info['role_id'],'status'=>$this::USER_STATUS]);
|
|
|
|
147
|
- if($role_info === false){
|
|
|
|
148
|
- $this->fail('当前用户角色被禁用',Code::USER_REGISTER_ERROE);
|
|
|
|
149
|
- }
|
|
|
|
150
|
- }
|
|
|
|
151
|
- //获取项目详情
|
150
|
+ public function autoAssembleParam($info){
|
|
152
|
$project = $this->getProjectInfo($info['project_id']);
|
151
|
$project = $this->getProjectInfo($info['project_id']);
|
|
153
|
$info['company'] = $project['company'] ?? '';
|
152
|
$info['company'] = $project['company'] ?? '';
|
|
154
|
$info['plan'] = Project::planMap()[$project['deploy_build']['plan']];
|
153
|
$info['plan'] = Project::planMap()[$project['deploy_build']['plan']];
|
|
@@ -160,6 +159,27 @@ class UserLoginLogic |
|
@@ -160,6 +159,27 @@ class UserLoginLogic |
|
160
|
}
|
159
|
}
|
|
161
|
|
160
|
|
|
162
|
/**
|
161
|
/**
|
|
|
|
162
|
+ * @remark :组装返回数据
|
|
|
|
163
|
+ * @name :getProjectInfo
|
|
|
|
164
|
+ * @author :lyh
|
|
|
|
165
|
+ * @method :post
|
|
|
|
166
|
+ * @time :2023/8/29 15:26
|
|
|
|
167
|
+ */
|
|
|
|
168
|
+ public function assembleParam($mobile,$project_id){
|
|
|
|
169
|
+ $info = $this->model->read(['mobile'=>$mobile,'project_id'=>$project_id],['id','mobile','status','role_id','token','name','project_id']);
|
|
|
|
170
|
+ //获取项目详情
|
|
|
|
171
|
+ $project = $this->getProjectInfo($project_id);
|
|
|
|
172
|
+ $info['company'] = $project['company'] ?? '';
|
|
|
|
173
|
+ $info['plan'] = Project::planMap()[$project['deploy_build']['plan']];
|
|
|
|
174
|
+ $info['domain'] = (!empty($project['deploy_optimize']['domain']) ?
|
|
|
|
175
|
+ $project['deploy_optimize']['domain'] : ($project['deploy_build']['test_domain'] ?? ''));
|
|
|
|
176
|
+ //保存项目缓存
|
|
|
|
177
|
+ Cache::add('user-'.$project_id,$project);
|
|
|
|
178
|
+ return $this->success($info);
|
|
|
|
179
|
+ }
|
|
|
|
180
|
+
|
|
|
|
181
|
+
|
|
|
|
182
|
+ /**
|
|
163
|
* @remark :获取项目数据详情
|
183
|
* @remark :获取项目数据详情
|
|
164
|
* @name :getProjectInfo
|
184
|
* @name :getProjectInfo
|
|
165
|
* @author :lyh
|
185
|
* @author :lyh
|