accessEnded = request()->query('access') === 'ended'; } public function login(CheckLoginAllowed $checkLoginAllowed): void { $this->email = trim($this->email); $this->validate( ['email' => ['required', 'string', 'email'], 'password' => ['required', 'string']], [ 'email.required' => __('auth.email_required'), 'email.email' => __('auth.email_invalid'), 'password.required' => __('auth.password_required'), ], ); $email = Str::lower(trim($this->email)); $throttleKey = Str::transliterate($email.'|'.request()->ip()); $ipThrottleKey = 'login-ip|'.request()->ip(); foreach ([$throttleKey => self::MAX_ATTEMPTS_PER_MINUTE, $ipThrottleKey => self::MAX_ATTEMPTS_PER_IP_PER_MINUTE] as $key => $maxAttempts) { if (RateLimiter::tooManyAttempts($key, $maxAttempts)) { throw ValidationException::withMessages([ 'email' => __('auth.throttle', ['seconds' => RateLimiter::availableIn($key)]), ]); } } $signedIn = Auth::attemptWhen( ['email' => $email, 'password' => $this->password], fn ($user): bool => $checkLoginAllowed->execute($user->getAuthIdentifier()), $this->remember, ); if (! $signedIn) { RateLimiter::hit($throttleKey); RateLimiter::hit($ipThrottleKey); $this->reset('password'); // One message for a wrong password and a disabled account, so the // form never confirms that a disabled account's password is right. throw ValidationException::withMessages(['email' => __('auth.failed')]); } RateLimiter::clear($throttleKey); session()->regenerate(); $this->redirectIntended(route('home')); } public function render(): mixed { return $this->view()->title(__('auth.login_title')); } }; ?>