- $this->middleware('guest', ['only' => ['getLogin', 'postLogin']]);
- $this->socialAuthService = $socialAuthService;
- $this->ldapService = $ldapService;
- $this->userRepo = $userRepo;
- $this->redirectPath = url('/');
- $this->redirectAfterLogout = url('/login');
- parent::__construct();
+ $this->validateLogin($request);
+ $username = $request->get($this->username());
+
+ // Check login throttling attempts to see if they've gone over the limit
+ if ($this->hasTooManyLoginAttempts($request)) {
+ Activity::logFailedLogin($username);
+ return $this->sendLockoutResponse($request);
+ }
+
+ try {
+ if ($this->attemptLogin($request)) {
+ return $this->sendLoginResponse($request);
+ }
+ } catch (LoginAttemptException $exception) {
+ Activity::logFailedLogin($username);
+
+ return $this->sendLoginAttemptExceptionResponse($exception, $request);
+ }
+
+ // On unsuccessful login attempt, Increment login attempts for throttling and log failed login.
+ $this->incrementLoginAttempts($request);
+ Activity::logFailedLogin($username);
+
+ // Throw validation failure for failed login
+ throw ValidationException::withMessages([
+ $this->username() => [trans('auth.failed')],
+ ])->redirectTo('/login');