<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
stephenjude / filament-two-factor-authentication example snippets
namespace App\Models;
...
use Stephenjude\FilamentTwoFactorAuthentication\TwoFactorAuthenticatable;
class User extends Authenticatable implements FilamentUser
{
...
use TwoFactorAuthenticatable;
...
use Stephenjude\FilamentTwoFactorAuthentication\TwoFactorAuthenticationPlugin;
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
TwoFactorAuthenticationPlugin::make()
->addTwoFactorMenuItem() // Add 2FA settings to user menu items
->enforceTwoFactorSetup() // Enforce 2FA setup for all users
])
}
...
use Stephenjude\FilamentTwoFactorAuthentication\Events\{RecoveryCodeReplaced,RecoveryCodesGenerated,TwoFactorAuthenticationChallenged,TwoFactorAuthenticationConfirmed,TwoFactorAuthenticationDisabled,TwoFactorAuthenticationEnabled,TwoFactorAuthenticationFailed,ValidTwoFactorAuthenticationCodeProvided};
protected $listen = [
TwoFactorAuthenticationChallenged::class => [
// Dispatched when a user is TwoFactorAuthenticationEnabled::class => [
// Dispatched when a user enables 2FA.
],
TwoFactorAuthenticationDisabled::class => [
// Dispatched when a user disables 2FA.
],
RecoveryCodeReplaced::class => [
// Dispatched after a user's recovery code is replaced.
],
RecoveryCodesGenerated::class => [
// Dispatched after a user's recovery codes are generated.
],
];