oauthService = $oauthService; $this->captchaService = $captchaService; } public function form(Schema $schema): Schema { $components = [ $this->getLoginFormComponent(), $this->getPasswordFormComponent(), $this->getRememberFormComponent(), $this->getOAuthFormComponent(), ]; if ($captchaComponent = $this->getCaptchaComponent()) { $components[] = $captchaComponent; } return $schema ->components($components); } private function getCaptchaComponent(): ?Component { return $this->captchaService->getActiveSchema()?->getFormComponent(); } protected function throwFailureValidationException(): never { $this->dispatch('reset-captcha'); throw ValidationException::withMessages([ 'data.login' => trans('filament-panels::pages/auth/login.messages.failed'), ]); } protected function getLoginFormComponent(): Component { return TextInput::make('login') ->label('Login') ->required() ->autocomplete() ->autofocus() ->extraInputAttributes(['tabindex' => 1]); } protected function getOAuthFormComponent(): Component { $actions = []; $oauthSchemas = $this->oauthService->getEnabled(); foreach ($oauthSchemas as $schema) { $id = $schema->getId(); $actions[] = Action::make("oauth_$id") ->label($schema->getName()) ->icon($schema->getIcon()) ->color(Color::generateV3Palette($schema->getHexColor())) ->url(route('auth.oauth.redirect', ['driver' => $id], false)); } return Actions::make($actions); } protected function getCredentialsFromFormData(array $data): array { $loginType = filter_var($data['login'], FILTER_VALIDATE_EMAIL) ? 'email' : 'username'; return [ $loginType => mb_strtolower($data['login']), 'password' => $data['password'], ]; } }