2FAuth/app/Extensions/WebauthnTwoFAuthUserProvider.php
2023-03-26 17:13:32 +02:00

26 lines
808 B
PHP

<?php
namespace App\Extensions;
use App\Models\WebAuthnAuthenticatable;
use Illuminate\Auth\EloquentUserProvider;
use Laragear\WebAuthn\Auth\WebAuthnUserProvider;
class WebauthnTwoFAuthUserProvider extends WebAuthnUserProvider
{
/**
* Validate a user against the given credentials.
*
* @param \App\Models\User $user
*/
public function validateCredentials($user, array $credentials) : bool
{
if ($user instanceof WebAuthnAuthenticatable && $this->isSignedChallenge($credentials)) {
return $this->validateWebAuthn();
}
// If the user disabled the fallback, we will validate the credential password.
return $user->preferences['useWebauthnOnly'] == false && EloquentUserProvider::validateCredentials($user, $credentials);
}
}