Skip to content

Commit

Permalink
Use validate credentials before attempting to login
Browse files Browse the repository at this point in the history
  • Loading branch information
Baspa committed Aug 28, 2024
1 parent 82c6bbe commit d57d0b0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Http/Livewire/Auth/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,11 @@ public function loginWithFortify(): LoginResponse | Redirector | null

$request = request()->merge($data);

if (! Filament::auth()->attempt($this->getCredentialsFromFormData($data), $data['remember'] ?? false)) {
if (! $this->validateCredentials($this->getCredentialsFromFormData($data))) {
$this->throwFailureValidationException();
}

return $this->loginPipeline($request)->then(function (Request $request) use ($data) {

if (! Filament::auth()->attempt($this->getCredentialsFromFormData($data), $data['remember'] ?? false)) {
$this->throwFailureValidationException();
}
Expand Down Expand Up @@ -177,4 +176,12 @@ protected function getAuthenticateFormAction(): Action
->label(__('filament-panels::pages/auth/login.form.actions.authenticate.label'))
->submit('authenticate');
}

protected function validateCredentials(array $credentials): bool

Check failure on line 180 in src/Http/Livewire/Auth/Login.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Vormkracht10\TwoFactorAuth\Http\Livewire\Auth\Login::validateCredentials() has parameter $credentials with no value type specified in iterable type array.
{
$provider = Filament::auth()->getProvider();
$user = $provider->retrieveByCredentials($credentials);

return $user && $provider->validateCredentials($user, $credentials);
}
}

0 comments on commit d57d0b0

Please sign in to comment.