1313use Filament \Schemas \Components \Component ;
1414use Filament \Schemas \Schema ;
1515use Filament \Support \Colors \Color ;
16+ use Filament \Support \Enums \Alignment ;
1617use Illuminate \Validation \ValidationException ;
1718
1819class Login extends BaseLogin
@@ -32,6 +33,12 @@ public function boot(OAuthService $oauthService, CaptchaService $captchaService,
3233
3334 public function form (Schema $ schema ): Schema
3435 {
36+ if (config ('auth.disable_password_login ' , false )) {
37+ return $ schema ->components ([
38+ $ this ->getOAuthFormComponent (),
39+ ]);
40+ }
41+
3542 $ components = [
3643 $ this ->getLoginFormComponent (),
3744 $ this ->getPasswordFormComponent (),
@@ -108,11 +115,22 @@ protected function getOAuthFormComponent(): Component
108115 ->url (route ('auth.oauth.redirect ' , ['driver ' => $ id ], false ));
109116 }
110117
111- return Actions::make ($ actions );
118+ return Actions::make ($ actions )->alignment (fn () => config ('auth.disable_password_login ' , false ) ? Alignment::Center : null );
119+ }
120+
121+ protected function getFormActions (): array
122+ {
123+ return config ('auth.disable_password_login ' , false ) ? [] : parent ::getFormActions ();
112124 }
113125
114126 protected function getCredentialsFromFormData (array $ data ): array
115127 {
128+ if (config ('auth.disable_password_login ' , false )) {
129+ throw ValidationException::withMessages ([
130+ 'data.login ' => trans ('auth.password_login_disabled ' ),
131+ ]);
132+ }
133+
116134 $ loginType = filter_var ($ data ['login ' ], FILTER_VALIDATE_EMAIL ) ? 'email ' : 'username ' ;
117135
118136 return [
0 commit comments