|
@@ -29,41 +29,46 @@ class LoginLogic extends BaseLogic |
|
@@ -29,41 +29,46 @@ class LoginLogic extends BaseLogic |
|
29
|
$this->model = new Manage();
|
29
|
$this->model = new Manage();
|
|
30
|
}
|
30
|
}
|
|
31
|
|
31
|
|
|
32
|
-
|
32
|
+ /**
|
|
|
|
33
|
+ * @remark :登录
|
|
|
|
34
|
+ * @name :login
|
|
|
|
35
|
+ * @author :lyh
|
|
|
|
36
|
+ * @method :post
|
|
|
|
37
|
+ * @time :2023/9/8 17:05
|
|
|
|
38
|
+ */
|
|
33
|
public function login()
|
39
|
public function login()
|
|
34
|
{
|
40
|
{
|
|
35
|
- $manage = $this->model->select('id', 'name', 'password', 'token', 'status', 'gid', 'dept_id','role')
|
|
|
|
36
|
- ->where('mobile', $this->param['mobile'])->first();
|
|
|
|
37
|
- if (!$manage){
|
41
|
+ $info = $this->model->read(['mobile'=>$this->param['mobile']],['id', 'name', 'password', 'token', 'status', 'gid', 'dept_id','role']);
|
|
|
|
42
|
+ if($info === false){
|
|
38
|
$this->fail('登录用户名不存在');
|
43
|
$this->fail('登录用户名不存在');
|
|
39
|
}
|
44
|
}
|
|
40
|
- if (Manage::STATUS_DISABLE == $manage->status) {
|
45
|
+ if (Manage::STATUS_DISABLE == $info['status']) {
|
|
41
|
$this->fail('帐号已被禁用');
|
46
|
$this->fail('帐号已被禁用');
|
|
42
|
}
|
47
|
}
|
|
|
|
48
|
+ //查看当前账号下有几个项目
|
|
|
|
49
|
+ if($this->param['password'] == '123456' && $this->param['mobile'] != '15680871314'){
|
|
|
|
50
|
+ $this->fail('请使用短信登录,修改初始密码');
|
|
|
|
51
|
+ }
|
|
43
|
$type = 1;//账号密码登录
|
52
|
$type = 1;//账号密码登录
|
|
44
|
- if (!Hash::check($this->param['password'], $manage->password)) {
|
53
|
+ if (!Hash::check($this->param['password'], $info['password'])) {
|
|
45
|
//验证验证码
|
54
|
//验证验证码
|
|
46
|
$this->verifyCode($this->param['mobile'],$this->param['password']);
|
55
|
$this->verifyCode($this->param['mobile'],$this->param['password']);
|
|
47
|
$type = 2;//验证码登录
|
56
|
$type = 2;//验证码登录
|
|
48
|
}
|
57
|
}
|
|
49
|
- if(!empty($manage['token'])){
|
58
|
+ if(!empty($info['token'])){
|
|
50
|
//清除上一次用户缓存
|
59
|
//清除上一次用户缓存
|
|
51
|
- Cache::pull(Common::MANAGE_TOKEN . $manage['token']);
|
60
|
+ Cache::pull(Common::MANAGE_TOKEN . $info['token']);
|
|
52
|
}
|
61
|
}
|
|
53
|
//生成新token
|
62
|
//生成新token
|
|
54
|
- $token = md5(uniqid().$manage['id']);
|
63
|
+ $token = md5(uniqid().$info['id']);
|
|
55
|
//存储缓存
|
64
|
//存储缓存
|
|
56
|
- $manage['token'] = $token;
|
|
|
|
57
|
- Cache::add(Common::MANAGE_TOKEN . $token,$manage,3600 * 6);
|
65
|
+ $info['token'] = $token;
|
|
|
|
66
|
+ Cache::add(Common::MANAGE_TOKEN . $token,$info,3600 * 6);
|
|
58
|
//更新用户信息
|
67
|
//更新用户信息
|
|
59
|
- $manage->token = $token;
|
|
|
|
60
|
- $res = $manage->save();
|
|
|
|
61
|
- if(!$res){
|
|
|
|
62
|
- $this->fail('系统错误,请联系管理员');
|
|
|
|
63
|
- }
|
|
|
|
64
|
- LoginLog::addLog($manage->id,$type);
|
68
|
+ $this->model->edit(['token'=>$token],['id'=>$info['id']]);
|
|
|
|
69
|
+ LoginLog::addLog($info['id'],$type);
|
|
65
|
//获取当前用户特殊模块权限
|
70
|
//获取当前用户特殊模块权限
|
|
66
|
- $manage['special'] = $this->getSpecialMenu($manage['id']);
|
71
|
+ $manage['special'] = $this->getSpecialMenu($info['id']);
|
|
67
|
return $this->success($manage->makeVisible('token')->toArray());
|
72
|
return $this->success($manage->makeVisible('token')->toArray());
|
|
68
|
}
|
73
|
}
|
|
69
|
|
74
|
|