mirror of
https://github.com/v2board/v2board.git
synced 2025-06-17 23:27:48 +08:00
update: config & custom password attack rule
This commit is contained in:
@ -189,10 +189,13 @@ class AuthController extends Controller
|
||||
$email = $request->input('email');
|
||||
$password = $request->input('password');
|
||||
|
||||
$passwordErrorCount = (int)Cache::get(CacheKey::get('PASSWORD_ERROR_LIMIT', $email), 0);
|
||||
|
||||
if ($passwordErrorCount >= 5) {
|
||||
abort(500, __('There are too many password errors, please try again after 30 minutes.'));
|
||||
if ((int)config('v2board.password_limit_enable', 1)) {
|
||||
$passwordErrorCount = (int)Cache::get(CacheKey::get('PASSWORD_ERROR_LIMIT', $email), 0);
|
||||
if ($passwordErrorCount >= (int)config('v2board.password_limit_count', 5)) {
|
||||
abort(500, __('There are too many password errors, please try again after :minute minutes.', [
|
||||
'minute' => config('v2board.password_limit_expire', 60)
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
$user = User::where('email', $email)->first();
|
||||
@ -205,11 +208,13 @@ class AuthController extends Controller
|
||||
$password,
|
||||
$user->password)
|
||||
) {
|
||||
Cache::put(
|
||||
CacheKey::get('PASSWORD_ERROR_LIMIT', $email),
|
||||
(int)$passwordErrorCount + 1,
|
||||
30 * 60
|
||||
);
|
||||
if ((int)config('v2board.password_limit_enable')) {
|
||||
Cache::put(
|
||||
CacheKey::get('PASSWORD_ERROR_LIMIT', $email),
|
||||
(int)$passwordErrorCount + 1,
|
||||
60 * (int)config('v2board.password_limit_expire', 60)
|
||||
);
|
||||
}
|
||||
abort(500, __('Incorrect email or password'));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user