正在显示
1 个修改的文件
包含
17 行增加
和
12 行删除
| @@ -38,11 +38,12 @@ class LoginLogic extends BaseLogic | @@ -38,11 +38,12 @@ class LoginLogic extends BaseLogic | ||
| 38 | */ | 38 | */ |
| 39 | public function login() | 39 | public function login() |
| 40 | { | 40 | { |
| 41 | - $info = $this->model->read(['mobile'=>$this->param['mobile']],['id', 'name', 'password', 'token', 'status', 'gid', 'dept_id','role']); | ||
| 42 | - if($info === false){ | 41 | + $manage = $this->model->select('id', 'name', 'password', 'token', 'status', 'gid', 'dept_id','role') |
| 42 | + ->where('mobile', $this->param['mobile'])->first(); | ||
| 43 | + if (!$manage){ | ||
| 43 | $this->fail('登录用户名不存在'); | 44 | $this->fail('登录用户名不存在'); |
| 44 | } | 45 | } |
| 45 | - if (Manage::STATUS_DISABLE == $info['status']) { | 46 | + if (Manage::STATUS_DISABLE == $manage->status) { |
| 46 | $this->fail('帐号已被禁用'); | 47 | $this->fail('帐号已被禁用'); |
| 47 | } | 48 | } |
| 48 | //查看当前账号下有几个项目 | 49 | //查看当前账号下有几个项目 |
| @@ -50,25 +51,29 @@ class LoginLogic extends BaseLogic | @@ -50,25 +51,29 @@ class LoginLogic extends BaseLogic | ||
| 50 | $this->fail('请使用短信登录,修改初始密码'); | 51 | $this->fail('请使用短信登录,修改初始密码'); |
| 51 | } | 52 | } |
| 52 | $type = 1;//账号密码登录 | 53 | $type = 1;//账号密码登录 |
| 53 | - if (!Hash::check($this->param['password'], $info['password'])) { | 54 | + if (!Hash::check($this->param['password'], $manage->password)) { |
| 54 | //验证验证码 | 55 | //验证验证码 |
| 55 | $this->verifyCode($this->param['mobile'],$this->param['password']); | 56 | $this->verifyCode($this->param['mobile'],$this->param['password']); |
| 56 | $type = 2;//验证码登录 | 57 | $type = 2;//验证码登录 |
| 57 | } | 58 | } |
| 58 | - if(!empty($info['token'])){ | 59 | + if(!empty($manage['token'])){ |
| 59 | //清除上一次用户缓存 | 60 | //清除上一次用户缓存 |
| 60 | - Cache::pull(Common::MANAGE_TOKEN . $info['token']); | 61 | + Cache::pull(Common::MANAGE_TOKEN . $manage['token']); |
| 61 | } | 62 | } |
| 62 | //生成新token | 63 | //生成新token |
| 63 | - $token = md5(uniqid().$info['id']); | 64 | + $token = md5(uniqid().$manage['id']); |
| 64 | //存储缓存 | 65 | //存储缓存 |
| 65 | - $info['token'] = $token; | ||
| 66 | - Cache::add(Common::MANAGE_TOKEN . $token,$info,3600 * 6); | 66 | + $manage['token'] = $token; |
| 67 | + Cache::add(Common::MANAGE_TOKEN . $token,$manage,3600); | ||
| 67 | //更新用户信息 | 68 | //更新用户信息 |
| 68 | - $this->model->edit(['token'=>$token],['id'=>$info['id']]); | ||
| 69 | - LoginLog::addLog($info['id'],$type); | 69 | + $manage->token = $token; |
| 70 | + $res = $manage->save(); | ||
| 71 | + if(!$res){ | ||
| 72 | + $this->fail('系统错误,请联系管理员'); | ||
| 73 | + } | ||
| 74 | + LoginLog::addLog($manage->id,$type); | ||
| 70 | //获取当前用户特殊模块权限 | 75 | //获取当前用户特殊模块权限 |
| 71 | - $manage['special'] = $this->getSpecialMenu($info['id']); | 76 | + $manage['special'] = $this->getSpecialMenu($manage['id']); |
| 72 | return $this->success($manage->makeVisible('token')->toArray()); | 77 | return $this->success($manage->makeVisible('token')->toArray()); |
| 73 | } | 78 | } |
| 74 | 79 |
-
请 注册 或 登录 后发表评论