mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-12-12 10:10:59 +01:00
26 lines
813 B
PHP
26 lines
813 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($user);
|
|
}
|
|
|
|
// If the user disabled the fallback, we will validate the credential password.
|
|
return $user->preferences['useWebauthnOnly'] == false && EloquentUserProvider::validateCredentials($user, $credentials);
|
|
}
|
|
}
|