label('Username') ->required() ->autofocus() ->extraInputAttributes(['tabindex' => 1]) ->autocomplete(); } protected function getCredentialsFromFormData(array $data): array { return [ 'username' => $data['username'], 'password' => $data['password'], ]; } public function authenticate(): ?LoginResponse { try { $this->rateLimit(5); } catch (TooManyRequestsException $exception) { $this->getRateLimitedNotification($exception)?->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::getCurrentPanel()))) { Filament::auth()->logout(); $this->throwFailureValidationException(); } elseif ($user->customer_id !== null) { Filament::auth()->logout(); throw ValidationException::withMessages([ 'data.username' => 'Incorrect username or password.', ]); } session()->regenerate(); return app(LoginResponse::class); } protected function throwFailureValidationException(): never { throw ValidationException::withMessages([ 'data.username' => __('filament-panels::pages/auth/login.messages.failed'), ]); } public function getTitle(): Htmlable|string { return __('Login'); } public function getHeading(): Htmlable|string { return __('Login'); } }