validate(); $key = 'login:'.md5(strtolower($this->email).'|'.request()->ip()); if (RateLimiter::tooManyAttempts($key, 5)) { throw ValidationException::withMessages([ 'email' => __('auth.too_many_attempts', ['seconds' => RateLimiter::availableIn($key)]), ]); } $user = User::where('email', $this->email)->first(); if (! $user || ! Hash::check($this->password, $user->password)) { RateLimiter::hit($key, 60); throw ValidationException::withMessages(['email' => __('auth.invalid_credentials')]); } RateLimiter::clear($key); // 2FA gate: hold the login until the TOTP code is verified. if ($user->hasTwoFactorEnabled()) { session()->put('2fa.user', $user->id); session()->put('2fa.remember', $this->remember); return $this->redirect(route('two-factor.challenge'), navigate: true); } Auth::login($user, $this->remember); session()->regenerate(); return $this->redirectIntended(route('dashboard'), navigate: true); } public function render() { return view('livewire.auth.login')->title(__('auth.title_login')); } }