mirror of
https://github.com/v2board/v2board.git
synced 2025-06-16 22:57:47 +08:00
update: password check limit
This commit is contained in:
@ -190,6 +190,12 @@ class AuthController extends Controller
|
||||
$email = $request->input('email');
|
||||
$password = $request->input('password');
|
||||
|
||||
$passwordErrorCount = (int)Cache::get('PASSWORD_ERROR_LIMIT') || 0;
|
||||
|
||||
if ($passwordErrorCount >= 5) {
|
||||
abort(500, __('Incorrect email or password'));
|
||||
}
|
||||
|
||||
$user = User::where('email', $email)->first();
|
||||
if (!$user) {
|
||||
abort(500, __('Incorrect email or password'));
|
||||
@ -200,6 +206,12 @@ class AuthController extends Controller
|
||||
$password,
|
||||
$user->password)
|
||||
) {
|
||||
$passwordErrorCount = Cache::get('PASSWORD_ERROR_LIMIT') || 0;
|
||||
Cache::put(
|
||||
CacheKey::get('PASSWORD_ERROR_LIMIT', $email),
|
||||
(int)$passwordErrorCount + 1,
|
||||
30 * 60
|
||||
);
|
||||
abort(500, __('Incorrect email or password'));
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,8 @@ class CacheKey
|
||||
'LAST_SEND_EMAIL_REMIND_TRAFFIC' => '最后发送流量邮件提醒',
|
||||
'SCHEDULE_LAST_CHECK_AT' => '计划任务最后检查时间',
|
||||
'REGISTER_IP_RATE_LIMIT' => '注册频率限制',
|
||||
'LAST_SEND_LOGIN_WITH_MAIL_LINK_TIMESTAMP' => '最后一次发送登入链接时间'
|
||||
'LAST_SEND_LOGIN_WITH_MAIL_LINK_TIMESTAMP' => '最后一次发送登入链接时间',
|
||||
'PASSWORD_ERROR_LIMIT' => '密码错误次数限制'
|
||||
];
|
||||
|
||||
public static function get(string $key, $uniqueValue)
|
||||
|
Reference in New Issue
Block a user