Skip to content

Commit

Permalink
fix(user-provider): Do not access rehash function in L10 (#101)
Browse files Browse the repository at this point in the history
This function was added in Laravel 11.
Currently, this causes an exception when using Fortify with 2FA and Laravel 10 together with WebAuthn.

In Fortify the function is called when it detects that it exists, for compatibility with Laravel 10. But since we implement this function in WebAuthn, we need to also add a check if this actually exists on the parent class.

So in Laravel 10 we will just ignore the function and do nothing. This should be a sufficient workaround to support both.
  • Loading branch information
saibotk authored Dec 29, 2024
1 parent dbdf65c commit d1fd316
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Auth/WebAuthnUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ protected function validateWebAuthn(WebAuthnAuthenticatable $user, array $creden
*/
public function rehashPasswordIfRequired(UserContract $user, array $credentials, bool $force = false): void
{
if (! $this->isSignedChallenge($credentials)) {
if (! $this->isSignedChallenge($credentials) && method_exists(get_parent_class($this), 'rehashPasswordIfRequired')) {

Check failure on line 126 in src/Auth/WebAuthnUserProvider.php

View workflow job for this annotation

GitHub Actions / 3️⃣ Static Analysis

Call to function method_exists() with 'Illuminate\\Auth\\EloquentUserProvider' and 'rehashPasswordIfReq…' will always evaluate to true.
parent::rehashPasswordIfRequired($user, $credentials, $force);
}
}
Expand Down

0 comments on commit d1fd316

Please sign in to comment.