validate(); $this->ensureIsNotRateLimited(); if (!auth()->attempt($this->only(['email', 'password'], $this->remember))) { RateLimiter::hit($this->throttleKey()); throw ValidationException::withMessages([ 'email' => trans('auth.failed'), ]); } RateLimiter::clear($this->throttleKey()); session()->regenerate(); Log::create([ 'user_id' => auth()?->user()?->id, 'content' => "Quote sent. {$quote}" ]); $this->redirect( session('url.intended', RouteServiceProvider::HOME), navigate: true ); } protected function ensureIsNotRateLimited(): void { if (!RateLimiter::tooManyAttempts($this->throttleKey(), 5)) { return; } event(new Lockout(request())); $seconds = RateLimiter::availableIn($this->throttleKey()); throw ValidationException::withMessages([ 'email' => trans('auth.throttle', [ 'seconds' => $seconds, 'minutes' => ceil($seconds / 60), ]), ]); } protected function throttleKey(): string { return Str::transliterate(Str::lower($this->email) . '|' . request()->ip()); } }; ?>