В настоящее время пять попыток входа в систему блокируют пользователя на одну минуту по умолчанию.Я хочу спроектировать систему следующим образом:
- После первых трех неудачных попыток входа в систему заблокируйте пользователя на 2 минуты.
- После этого для следующих двух неудачных попыток входа в систему (чтоэто всего 5-й раз), заблокируйте пользователя на 5 минут.
ThrottlesLogins.php
public function maxAttempts()
{
return property_exists($this, 'maxAttempts') ? $this->maxAttempts : 2;
}
public function decayMinutes()
{
return property_exists($this, 'decayMinutes') ? $this->decayMinutes : 2;
}
LoginController.php
public function adminLogin(Request $request)
{
$this->validate($request, [
'email' => 'required|email',
'password' => 'required|min:6'
]);
$key = $this->throttleKey($request);
$rateLimiter = $this->limiter();
// Check if the user has too many login attempts.
if ($this->hasTooManyLoginAttempts($request)) {
$attempts = $rateLimiter->attempts($key);
$rateLimiter->clear($key);
if ($attempts === 5) {
$this->decayMinutes = 5;
}
for ($i = 0; $i < $attempts; $i++) {
$this->incrementLoginAttempts($request);
}
$this->fireLockoutEvent($request); // Fire the lockout event.
return $this->sendLockoutResponse($request); //Redirect the user back after lockout.
}
if (Auth::guard('admin')->attempt(['email' => $request->email,
'password' => $request->password], $request->get('remember'))) {
return redirect()->intended('/admin');
}
// Keep track of login attempts from the user.
$this->incrementLoginAttempts($request);
return back()->withInput($request->only('email', 'remember'));
}
Я уже следовал этому: Переполнение стека
Но это не решает мою проблему.Как мне добиться такой системы?