2FAuth/app/Extensions/WebauthnTwoFAuthUserProvider.php

26 lines
813 B
PHP
Raw Normal View History

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