PHP code example of jeffersongoncalves / filament-multifactor-passkeys

1. Go to this page and download the library: Download jeffersongoncalves/filament-multifactor-passkeys library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jeffersongoncalves / filament-multifactor-passkeys example snippets


use Filament\Models\Contracts\FilamentUser;
use Illuminate\Foundation\Auth\User as Authenticatable;
use JeffersonGoncalves\Filament\MultiFactorPasskeys\Contracts\HasPasskeyAuthentication;
use Spatie\LaravelPasskeys\Models\Concerns\InteractsWithPasskeys;

class User extends Authenticatable implements FilamentUser, HasPasskeyAuthentication
{
    use InteractsWithPasskeys;

    public function hasPasskeyAuthentication(): bool
    {
        return $this->passkeys()->exists();
    }

    // ...
}

use Filament\Panel;
use JeffersonGoncalves\Filament\MultiFactorPasskeys\MultiFactorPasskeysPlugin;
use JeffersonGoncalves\Filament\MultiFactorPasskeys\PasskeyAuthentication;

public function panel(Panel $panel): Panel
{
    return $panel
        // ...
        ->multiFactorAuthentication([
            PasskeyAuthentication::make(),
        ])
        ->plugin(MultiFactorPasskeysPlugin::make());
}

PasskeyAuthentication::make()
    ->redirectUrlUsing(fn () => route('dashboard'));

return [
    'redirect' => '/dashboard',
];
bash
php artisan vendor:publish --tag="passkeys-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="passkeys-config"
bash
php artisan vendor:publish --tag="filament-multifactor-passkeys-config"