|
...
|
...
|
@@ -29,41 +29,46 @@ class LoginLogic extends BaseLogic |
|
|
|
$this->model = new Manage();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :登录
|
|
|
|
* @name :login
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/9/8 17:05
|
|
|
|
*/
|
|
|
|
public function login()
|
|
|
|
{
|
|
|
|
$manage = $this->model->select('id', 'name', 'password', 'token', 'status', 'gid', 'dept_id','role')
|
|
|
|
->where('mobile', $this->param['mobile'])->first();
|
|
|
|
if (!$manage){
|
|
|
|
$info = $this->model->read(['mobile'=>$this->param['mobile']],['id', 'name', 'password', 'token', 'status', 'gid', 'dept_id','role']);
|
|
|
|
if($info === false){
|
|
|
|
$this->fail('登录用户名不存在');
|
|
|
|
}
|
|
|
|
if (Manage::STATUS_DISABLE == $manage->status) {
|
|
|
|
if (Manage::STATUS_DISABLE == $info['status']) {
|
|
|
|
$this->fail('帐号已被禁用');
|
|
|
|
}
|
|
|
|
//查看当前账号下有几个项目
|
|
|
|
if($this->param['password'] == '123456' && $this->param['mobile'] != '15680871314'){
|
|
|
|
$this->fail('请使用短信登录,修改初始密码');
|
|
|
|
}
|
|
|
|
$type = 1;//账号密码登录
|
|
|
|
if (!Hash::check($this->param['password'], $manage->password)) {
|
|
|
|
if (!Hash::check($this->param['password'], $info['password'])) {
|
|
|
|
//验证验证码
|
|
|
|
$this->verifyCode($this->param['mobile'],$this->param['password']);
|
|
|
|
$type = 2;//验证码登录
|
|
|
|
}
|
|
|
|
if(!empty($manage['token'])){
|
|
|
|
if(!empty($info['token'])){
|
|
|
|
//清除上一次用户缓存
|
|
|
|
Cache::pull(Common::MANAGE_TOKEN . $manage['token']);
|
|
|
|
Cache::pull(Common::MANAGE_TOKEN . $info['token']);
|
|
|
|
}
|
|
|
|
//生成新token
|
|
|
|
$token = md5(uniqid().$manage['id']);
|
|
|
|
$token = md5(uniqid().$info['id']);
|
|
|
|
//存储缓存
|
|
|
|
$manage['token'] = $token;
|
|
|
|
Cache::add(Common::MANAGE_TOKEN . $token,$manage,3600 * 6);
|
|
|
|
$info['token'] = $token;
|
|
|
|
Cache::add(Common::MANAGE_TOKEN . $token,$info,3600 * 6);
|
|
|
|
//更新用户信息
|
|
|
|
$manage->token = $token;
|
|
|
|
$res = $manage->save();
|
|
|
|
if(!$res){
|
|
|
|
$this->fail('系统错误,请联系管理员');
|
|
|
|
}
|
|
|
|
LoginLog::addLog($manage->id,$type);
|
|
|
|
$this->model->edit(['token'=>$token],['id'=>$info['id']]);
|
|
|
|
LoginLog::addLog($info['id'],$type);
|
|
|
|
//获取当前用户特殊模块权限
|
|
|
|
$manage['special'] = $this->getSpecialMenu($manage['id']);
|
|
|
|
$manage['special'] = $this->getSpecialMenu($info['id']);
|
|
|
|
return $this->success($manage->makeVisible('token')->toArray());
|
|
|
|
}
|
|
|
|
|
...
|
...
|
|