|
|
@@ -88,6 +88,8 @@ class LoginForm extends Model {
|
|
|
if(isset($this->_user)){
|
|
|
AdminLoginLogger::fail($this->_user,$returnResult);
|
|
|
}
|
|
|
+ // 失败写入缓存锁
|
|
|
+ Yii::$app->redis->incrby('FAIL_NUMS:' . $this->adminName, 1);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -97,6 +99,9 @@ class LoginForm extends Model {
|
|
|
Admin::updateAllCounters([
|
|
|
'LOGIN_NUMS' => 1,
|
|
|
], 'ADMIN_NAME=:ADMIN_NAME', ['ADMIN_NAME' => $this->adminName]);
|
|
|
+
|
|
|
+ // 失败写入缓存锁
|
|
|
+ Yii::$app->redis->delete('FAIL_NUMS:' . $this->adminName);
|
|
|
}
|
|
|
/**
|
|
|
* 登录
|
|
|
@@ -114,6 +119,13 @@ class LoginForm extends Model {
|
|
|
if(!$this->_user){
|
|
|
throw new Exception('账号不存在');
|
|
|
}
|
|
|
+ // 失败次数到达上限次数
|
|
|
+ $loginFailNums = Yii::$app->redis->get('FAIL_NUMS:' . $this->adminName) ?? 0;
|
|
|
+ if ($loginFailNums >= 3) {
|
|
|
+ $this->_updateFailTimes($transaction,'用户名或者密码错误');
|
|
|
+ throw new Exception('用户名或者密码错误');
|
|
|
+ }
|
|
|
+
|
|
|
if(!$this->_user['IS_ENABLE']){
|
|
|
$this->_updateFailTimes($transaction,'账号已经被锁定,无法登录');
|
|
|
throw new Exception('用户名或者密码错误');
|