anonaddy/app/Services/Webauthn.php
2023-03-09 12:49:33 +00:00

26 lines
662 B
PHP

<?php
namespace App\Services;
use App\Models\WebauthnKey;
use Illuminate\Contracts\Auth\Authenticatable as User;
use LaravelWebauthn\Services\Webauthn as ServicesWebauthn;
class Webauthn extends ServicesWebauthn
{
/**
* Test if the user has one or more webauthn key.
*/
public static function enabled(User $user): bool
{
return static::webauthnEnabled() && static::hasKey($user);
}
/**
* Detect if user has a key that is enabled.
*/
public static function hasKey(User $user): bool
{
return WebauthnKey::where('user_id', $user->getAuthIdentifier())->where('enabled', true)->count() > 0;
}
}