1. Go to this page and download the library: Download vormkracht10/filament-2fa 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/ */
vormkracht10 / filament-2fa example snippets
use Vormkracht10\TwoFactorAuth\TwoFactorAuthPlugin;
// ...
->plugin(TwoFactorAuthPlugin::make())
class User extends Authenticatable implements FilamentUser
{
use HasApiTokens, HasFactory, Notifiable, TwoFactorAuthenticatable;
// ...
}
use Vormkracht10\TwoFactorAuth\Enums\TwoFactorType;
// ...
protected function casts(): array
{
return [
'two_factor_type' => TwoFactorType::class,
];
}
use Laravel\Fortify\Events\TwoFactorAuthenticationChallenged;
use Laravel\Fortify\Events\TwoFactorAuthenticationEnabled;
use Vormkracht10\TwoFactorAuth\Listeners\SendTwoFactorCodeListener;
// ...
public function boot(): void
{
Event::listen([
TwoFactorAuthenticationChallenged::class,
TwoFactorAuthenticationEnabled::class
], SendTwoFactorCodeListener::class);
}
use Laravel\Fortify\Events\TwoFactorAuthenticationEnabled;
use Laravel\Fortify\Events\TwoFactorAuthenticationChallenged;
use Vormkracht10\TwoFactorAuth\Listeners\SendTwoFactorCodeListener;
// ...
protected $listen = [
TwoFactorAuthenticationChallenged::class => [
SendTwoFactorCodeListener::class,
],
TwoFactorAuthenticationEnabled::class => [
SendTwoFactorCodeListener::class,
],
];