Skip to content

Commit

Permalink
Use retrieveByCredentials() on the User Provider instead of a hardc…
Browse files Browse the repository at this point in the history
…oded Eloquent query (#582)
  • Loading branch information
pascalbaljet authored Dec 19, 2024
1 parent 79c6b0a commit 48fb1eb
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Actions/RedirectIfTwoFactorAuthenticatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,17 @@ protected function validateCredentials($request)
});
}

$model = $this->guard->getProvider()->getModel();
$provider = $this->guard->getProvider();

return tap($model::where(Fortify::username(), $request->{Fortify::username()})->first(), function ($user) use ($request) {
if (! $user || ! $this->guard->getProvider()->validateCredentials($user, ['password' => $request->password])) {
return tap($provider->retrieveByCredentials($request->only(Fortify::username(), 'password')), function ($user) use ($provider, $request) {
if (! $user || ! $provider->validateCredentials($user, ['password' => $request->password])) {
$this->fireFailedEvent($request, $user);

$this->throwFailedAuthenticationException($request);
}

if (config('hashing.rehash_on_login', true) && method_exists($this->guard->getProvider(), 'rehashPasswordIfRequired')) {
$this->guard->getProvider()->rehashPasswordIfRequired($user, ['password' => $request->password]);
if (config('hashing.rehash_on_login', true) && method_exists($provider, 'rehashPasswordIfRequired')) {
$provider->rehashPasswordIfRequired($user, ['password' => $request->password]);
}
});
}
Expand Down

0 comments on commit 48fb1eb

Please sign in to comment.