登录次数限制
This commit is contained in:
@@ -32,7 +32,7 @@ class LoginController extends BaseAdminController
|
||||
$redis = Yii::$app->redis;
|
||||
$errNum = $redis->get($key);
|
||||
if ($errNum >= $maxAttempts) {
|
||||
throw new Exception("已被锁定,30分钟内无法重试,解锁时间:". date('Y-m-d H:i:s', time() + $redis->ttl($key)));
|
||||
throw new Exception("当前账号因频繁登录已被锁定,30分钟内无法重试,预计解锁时间:". date('Y-m-d H:i:s', time() + $redis->ttl($key)));
|
||||
}
|
||||
$model = new LoginForm();
|
||||
|
||||
@@ -84,7 +84,7 @@ class LoginController extends BaseAdminController
|
||||
// 如果是第一次累加,设置过期时间
|
||||
if ($currentValue == 5) {
|
||||
$redis->expire($key, $expireTime);
|
||||
throw new Exception("已被锁定,30分钟内无法重试,解锁时间:". date('Y-m-d H:i:s', time() + $redis->ttl($key)));
|
||||
throw new Exception("当前账号因频繁登录已被锁定,30分钟内无法重试,预计解锁时间:". date('Y-m-d H:i:s', time() + $redis->ttl($key)));
|
||||
}
|
||||
}
|
||||
throw new Exception($e->getMessage().' 还有'.($maxAttempts - $currentValue).'次机会');
|
||||
|
||||
Reference in New Issue
Block a user