|
|
@@ -91,7 +91,8 @@ class LoginForm extends Model {
|
|
|
AdminLoginLogger::fail($this->_user,$returnResult);
|
|
|
}
|
|
|
// 失败写入缓存锁
|
|
|
- Yii::$app->redis->incrby('FAIL_NUMS:' . $this->adminName, 1);
|
|
|
+ $loginFailNums = Yii::$app->redis->get('FAIL_NUMS:' . $this->adminName) ?? 0;
|
|
|
+ Yii::$app->redis->set('FAIL_NUMS:' . $this->adminName, $loginFailNums + 1);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -125,25 +126,24 @@ class LoginForm extends Model {
|
|
|
$loginFailNums = Yii::$app->redis->get('FAIL_NUMS:' . $this->adminName) ?? 0;
|
|
|
LoggerTool::info('FAIL_NUMS:' . $this->adminName . ': ' . $loginFailNums);
|
|
|
if ($loginFailNums >= 3) {
|
|
|
- $this->_updateFailTimes($transaction, '用户名或者密码错误1');
|
|
|
throw new Exception('用户名或者密码错误1');
|
|
|
}
|
|
|
// 校验邮箱验证码
|
|
|
-// $codeObj = EmailLog::find()
|
|
|
-// ->where('ADMIN_ID=:ADMIN_ID AND EMAIL=:EMAIL',
|
|
|
-// [
|
|
|
-// ':ADMIN_ID' => $this->_user['ID'],
|
|
|
-// ':EMAIL' => $this->_user['EMAIL'],
|
|
|
-// ])
|
|
|
-// ->orderBy('CREATED_AT DESC')
|
|
|
-// ->one()
|
|
|
-// ->toArray();
|
|
|
-// if (!$codeObj || !$codeObj['CODE'] || $codeObj['CODE'] != $this->code) {
|
|
|
-// throw new Exception('邮箱验证码不正确,无法登录');
|
|
|
-// }
|
|
|
-// if ($codeObj['CREATED_AT'] + 5 * 60 < time()) {
|
|
|
-// throw new Exception('验证码已过期, 请重新获取验证码');
|
|
|
-// }
|
|
|
+ $codeObj = EmailLog::find()
|
|
|
+ ->where('ADMIN_ID=:ADMIN_ID AND EMAIL=:EMAIL',
|
|
|
+ [
|
|
|
+ ':ADMIN_ID' => $this->_user['ID'],
|
|
|
+ ':EMAIL' => $this->_user['EMAIL'],
|
|
|
+ ])
|
|
|
+ ->orderBy('CREATED_AT DESC')
|
|
|
+ ->one()
|
|
|
+ ->toArray();
|
|
|
+ if (!$codeObj || !$codeObj['CODE'] || $codeObj['CODE'] != $this->code) {
|
|
|
+ throw new Exception('邮箱验证码不正确,无法登录');
|
|
|
+ }
|
|
|
+ if ($codeObj['CREATED_AT'] + 5 * 60 < time()) {
|
|
|
+ throw new Exception('验证码已过期, 请重新获取验证码');
|
|
|
+ }
|
|
|
|
|
|
if(!$this->_user['IS_ENABLE']){
|
|
|
$this->_updateFailTimes($transaction,'账号已经被锁定,无法登录');
|