validate((new LoginRequest())->rules()); $key = strtolower($this->email).'|'.request()->ip(); if (RateLimiter::tooManyAttempts($key, 5)) { throw ValidationException::withMessages([ 'email' => 'Слишком много попыток входа. Попробуйте позже.', ]); } if (!Auth::attempt(['email' => $this->email, 'password' => $this->password], $this->remember)) { RateLimiter::hit($key, 60); throw ValidationException::withMessages([ 'email' => 'Неверный email или пароль.', ]); } RateLimiter::clear($key); request()->session()->regenerate(); $user = auth()->user(); $user->forceFill(['last_login_at' => now()])->save(); $activityLogService->log($user, $user, $user->id, 'login', 'Вход в систему', request()->ip()); return redirect()->intended(route(RoleRedirect::routeFor($user))); } public function render() { return view('livewire.auth.login-page') ->title('Вход в систему'); } }