|
@@ -278,7 +278,7 @@ class EmployeeService extends Service
|
|
|
public function loginRule($data){
|
|
|
if($this->isEmpty($data,'account')) return [false,'账号不能为空!'];
|
|
|
if($this->isEmpty($data,'password')) return [false,'密码不能为空!'];
|
|
|
- if($this->isLoginlimitation($data['account'])) return [false,'账号密码输入错误过多,30分钟内限制登录!'];
|
|
|
+ if(LoginService::isLoginlimitation($data['account'])) return [false,'账号密码输入错误过多,30分钟内限制登录!'];
|
|
|
|
|
|
$res = Employee::where('del_time',0)
|
|
|
->where('account', $data['account'])
|
|
@@ -291,40 +291,13 @@ class EmployeeService extends Service
|
|
|
|
|
|
//密码校验
|
|
|
if(! Hash::check($data['password'], $res['password'])) {
|
|
|
- $msg = $this->errorSetLogin($data['account']);
|
|
|
+ $msg = LoginService::errorSetLogin($data['account']);
|
|
|
return [false,$msg];
|
|
|
}
|
|
|
|
|
|
return [true, ['id'=>$res['id'], 'name'=>$res['emp_name'], 'account' => $res['account']]];
|
|
|
}
|
|
|
|
|
|
- //设置登录错误次数(超过三次)
|
|
|
- public function errorSetLogin($cacheKey){
|
|
|
- if(Cache::has($cacheKey)){
|
|
|
- $num = Cache::get($cacheKey);
|
|
|
-
|
|
|
- $num++;
|
|
|
- Cache::put($cacheKey,$num,30);
|
|
|
- if($num >= 3){
|
|
|
- return ['账号密码输入错误3次,30分钟内限制登录!'];
|
|
|
- }else{
|
|
|
- return ['账号密码输入错误第'. $num .'次!'];
|
|
|
- }
|
|
|
- }else{
|
|
|
- Cache::add($cacheKey,1,30);
|
|
|
- return ['密码输入错误!'];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //判断是否限制登录
|
|
|
- public function isLoginlimitation($cacheKey){
|
|
|
- if(Cache::has($cacheKey)){
|
|
|
- $num = Cache::get($cacheKey);
|
|
|
- if($num >= 3) return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
public static function checkUser($userId){
|
|
|
$res = Employee::where('id', $userId)
|
|
|
->where('del_time',0)
|