Форма управления кодом в Filament
Давайте соберём форму управления. На странице профиля работник задаёт код, который потом ждёт вход. Смотрим /admin/profile.
Метод getManagementSchemaComponents
возвращает поля профиля
для провайдера. Добавим
цифровое поле в
PinAuthentication.php:
<?php
namespace App\Filament\Auth;
use App\Models\User;
use Filament\Auth\MultiFactor\Contracts\MultiFactorAuthenticationProvider;
use Filament\Forms\Components\TextInput;
use Illuminate\Contracts\Auth\Authenticatable;
class PinAuthentication implements MultiFactorAuthenticationProvider
{
public static function make(): static
{
return app(static::class);
}
public function getId(): string
{
return 'pin';
}
public function getLoginFormLabel(): string
{
return 'PIN';
}
public function isEnabled(Authenticatable $user): bool
{
if (! ($user instanceof User)) {
return false;
}
return (bool) $user->pin_enabled;
}
public function getManagementSchemaComponents(): array
{
return [
TextInput::make('pin_code')
->label('PIN code')
->password()
->numeric()
->required(),
];
}
public function getChallengeFormComponents(Authenticatable $user): array
{
return [
TextInput::make('code')
->label('PIN code')
->required(),
];
}
}
?>
На странице профиля дайте задать код, который потом спросит вход.