|
|
@@ -89,6 +89,8 @@ class LoginForm extends Model {
|
|
|
if(isset($this->_user)){
|
|
|
AdminLoginLogger::fail($this->_user,$returnResult);
|
|
|
}
|
|
|
+ // 失败写入缓存锁
|
|
|
+ Yii::$app->redis->incrby('FAIL_NUMS:' . $this->adminName, 1);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -98,6 +100,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);
|
|
|
}
|
|
|
/**
|
|
|
* 登录
|
|
|
@@ -115,6 +120,12 @@ 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('用户名或者密码错误');
|
|
|
+ }
|
|
|
// 校验邮箱验证码
|
|
|
$codeObj = EmailLog::find()
|
|
|
->where('ADMIN_ID=:ADMIN_ID AND EMAIL=:EMAIL',
|
|
|
@@ -134,7 +145,7 @@ class LoginForm extends Model {
|
|
|
|
|
|
if(!$this->_user['IS_ENABLE']){
|
|
|
$this->_updateFailTimes($transaction,'账号已经被锁定,无法登录');
|
|
|
- throw new Exception('账号已经被锁定,无法登录');
|
|
|
+ throw new Exception('用户名或者密码错误');
|
|
|
}
|
|
|
if (!$this->_user->validatePassword($this->password)) {
|
|
|
$this->_updateFailTimes($transaction,'用户名或者密码错误');
|
|
|
@@ -144,7 +155,7 @@ class LoginForm extends Model {
|
|
|
$bindIp = trim($this->_user['BIND_IP']);
|
|
|
if(!empty($bindIp) && !(new LoginIpChecker(Yii::$app->request->getUserIP(), $bindIp))->validate()){
|
|
|
$this->_updateFailTimes($transaction,'登录IP与此账号绑定的IP不符');
|
|
|
- throw new Exception('登录IP与此账号绑定的IP不符'.$bindIp);
|
|
|
+ throw new Exception('用户名或者密码错误');
|
|
|
}
|
|
|
|
|
|
//需要修改密码
|