Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion app/Filament/Pages/Auth/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Filament\Schemas\Components\Component;
use Filament\Schemas\Schema;
use Filament\Support\Colors\Color;
use Filament\Support\Enums\Alignment;
use Illuminate\Validation\ValidationException;

class Login extends BaseLogin
Expand All @@ -32,6 +33,12 @@ public function boot(OAuthService $oauthService, CaptchaService $captchaService,

public function form(Schema $schema): Schema
{
if (config('auth.disable_password_login', false)) {
return $schema->components([
$this->getOAuthFormComponent(),
]);
}

$components = [
$this->getLoginFormComponent(),
$this->getPasswordFormComponent(),
Expand Down Expand Up @@ -108,11 +115,22 @@ protected function getOAuthFormComponent(): Component
->url(route('auth.oauth.redirect', ['driver' => $id], false));
}

return Actions::make($actions);
return Actions::make($actions)->alignment(fn () => config('auth.disable_password_login', false) ? Alignment::Center : null);
}

protected function getFormActions(): array
{
return config('auth.disable_password_login', false) ? [] : parent::getFormActions();
}

protected function getCredentialsFromFormData(array $data): array
{
if (config('auth.disable_password_login', false)) {
throw ValidationException::withMessages([
'data.login' => trans('auth.password_login_disabled'),
]);
}

$loginType = filter_var($data['login'], FILTER_VALIDATE_EMAIL) ? 'email' : 'username';

return [
Expand Down
2 changes: 2 additions & 0 deletions config/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

return [

'disable_password_login' => env('AUTH_DISABLE_PASSWORD_LOGIN', false),
Comment thread
Boy132 marked this conversation as resolved.

'lockout' => [
'time' => 2,
'attempts' => 3,
Expand Down
1 change: 1 addition & 0 deletions lang/en/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
'password' => 'The provided password is incorrect.',
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
'2fa_must_be_enabled' => 'The administrator has required that 2-Factor Authentication must be enabled for your account in order to use the Panel.',
'password_login_disabled' => 'Password login is disabled. Please use an OAuth provider to sign in.',

];
Loading