rateLimit(5); } catch (TooManyRequestsException $exception) { Notification::make() ->title(__('filament-panels::pages/auth/login.notifications.throttled.title', [ 'seconds' => $exception->secondsUntilAvailable, 'minutes' => ceil($exception->secondsUntilAvailable / 60), ])) ->body(array_key_exists('body', __('filament-panels::pages/auth/login.notifications.throttled') ?: []) ? __('filament-panels::pages/auth/login.notifications.throttled.body', [ 'seconds' => $exception->secondsUntilAvailable, 'minutes' => ceil($exception->secondsUntilAvailable / 60), ]) : null) ->danger() ->send(); return null; } $data = $this->form->getState(); if (! Filament::auth()->attempt($this->getCredentialsFromFormData($data), $data['remember'] ?? false)) { $this->throwFailureValidationException(); } $user = Filament::auth()->user(); if ( ($user instanceof FilamentUser) && (! $user->canAccessPanel(Filament::getCurrentOrDefaultPanel())) ) { Filament::auth()->logout(); $this->throwFailureValidationException(); } session()->regenerate(); return resolve(LoginResponse::class); } protected function throwFailureValidationException(): never { throw ValidationException::withMessages([ 'data.username' => __('filament-panels::pages/auth/login.messages.failed'), ]); } protected function getFormSchema(): array { return [ TextInput::make('username') ->label(__('filament::login.fields.username.label')) ->required() ->autocomplete(), TextInput::make('password') ->label(__('filament::login.fields.password.label')) ->password() ->required(), Checkbox::make('remember') ->label(__('filament::login.fields.remember.label')), ]; } #[\Override] protected function getEmailFormComponent(): Component { return TextInput::make('username') ->label(__('filament::login.fields.username.label')) ->required() ->autocomplete() ->autofocus() ->extraInputAttributes(['tabindex' => 1]); } /** * @param array $data * * @return array */ #[\Override] protected function getCredentialsFromFormData(array $data): array { return [ 'username' => $data['username'], 'password' => $data['password'], ]; } }