Увеличьте время нескольких неудачных попыток входа в Laravel 5.5 - PullRequest
1 голос
/ 05 мая 2019

В настоящее время пять попыток входа в систему блокируют пользователя на одну минуту по умолчанию.Я хочу спроектировать систему следующим образом:

  1. После первых трех неудачных попыток входа в систему заблокируйте пользователя на 2 минуты.
  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'));
}

Я уже следовал этому: Переполнение стека

Но это не решает мою проблему.Как мне добиться такой системы?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...