diff --git a/application/api/model/Login.php b/application/api/model/Login.php index dbcbaaf..3a82cfb 100644 --- a/application/api/model/Login.php +++ b/application/api/model/Login.php @@ -299,19 +299,8 @@ class Login extends Model } //今天误次数 $sms_count = db::name('sms_error')->where(['mobile' => $user_name,'createtime' => ['between', [strtotime(date('Y-m-d')), time()]]])->count(); - $count_sms = max(5 - $sms_count, 0); - if (md5($password) != $user_info['password']) { - $data = [ - 'mobile' => $user_name, - 'type' => 2, - 'sms' => $password, - 'createtime'=> time(), - ]; - db::name('sms_error')->insert($data); - return ['code' => 0, 'msg' => '密码错误,'.$count_sms.'次后账号将被封禁24小时', 'data' => null]; - } - if ($sms_count >= 5) { + if ($sms_count >= 5) { $user_id = db::name('user')->where('mobile', $user_name)->value('id'); $block_num = db::name('block')->where(['type' => 1, 'type_text' => $user_id])->find(); if(!$block_num){ @@ -330,10 +319,26 @@ class Login extends Model return ['code' => 0, 'msg' => '登录错误次数过多,账号已被封禁,请联系管理员处理','data' =>null]; } + $count_sms = max(5 - $sms_count, 0); + if (md5($password) != $user_info['password']) { + $data = [ + 'mobile' => $user_name, + 'type' => 2, + 'sms' => $password, + 'createtime'=> time(), + ]; + db::name('sms_error')->insert($data); + return ['code' => 0, 'msg' => '密码错误,'.$count_sms.'次后账号将被封禁24小时', 'data' => null]; + } + $login = $this->login($user_info,$system,$login_device); if($login['code'] != 1){ return $login; } + + //登陆成功后 把所有的登录错误删除掉 + db::name('sms_error')->where(['mobile' => $user_name])->delete(); + return ['code' => 1, 'msg' => '登录成功', 'data' => $login['data']]; } diff --git a/application/api/model/Sms.php b/application/api/model/Sms.php index 4e9cc73..0e667e3 100644 --- a/application/api/model/Sms.php +++ b/application/api/model/Sms.php @@ -56,6 +56,8 @@ class Sms extends Model } } db::name('sms')->where(['mobile' => $mobile, 'event' => $type])->delete(); + //登陆成功后 把所有的登录错误删除掉 + db::name('sms_error')->where(['mobile' => $mobile])->delete(); return ['code' =>1, 'msg' =>'验证码正确','data' =>null]; } else { //验证码错误次数