diff --git a/app/Exceptions/Service/User/TwoFactorAuthenticationTokenInvalid.php b/app/Exceptions/Service/User/TwoFactorAuthenticationTokenInvalid.php index 38771a453..d5f09884c 100644 --- a/app/Exceptions/Service/User/TwoFactorAuthenticationTokenInvalid.php +++ b/app/Exceptions/Service/User/TwoFactorAuthenticationTokenInvalid.php @@ -6,9 +6,9 @@ use App\Exceptions\DisplayException; class TwoFactorAuthenticationTokenInvalid extends DisplayException { - /** - * TwoFactorAuthenticationTokenInvalid constructor. - */ + public string $title = 'Invalid 2FA Code'; + public string $icon = 'tabler-2fa'; + public function __construct() { parent::__construct('The provided two-factor authentication token was not valid.'); diff --git a/app/Filament/Resources/UserResource/Pages/EditUser.php b/app/Filament/Resources/UserResource/Pages/EditUser.php index e12e4de40..4750ce28f 100644 --- a/app/Filament/Resources/UserResource/Pages/EditUser.php +++ b/app/Filament/Resources/UserResource/Pages/EditUser.php @@ -3,6 +3,7 @@ namespace App\Filament\Resources\UserResource\Pages; use App\Filament\Resources\UserResource; +use App\Services\Exceptions\FilamentExceptionHandler; use Filament\Actions; use Filament\Resources\Pages\EditRecord; use App\Models\User; @@ -77,4 +78,9 @@ class EditUser extends EditRecord { return []; } + + public function exception($exception, $stopPropagation): void + { + (new FilamentExceptionHandler())->handle($exception, $stopPropagation); + } } diff --git a/app/Services/Exceptions/FilamentExceptionHandler.php b/app/Services/Exceptions/FilamentExceptionHandler.php new file mode 100644 index 000000000..2898f6c2c --- /dev/null +++ b/app/Services/Exceptions/FilamentExceptionHandler.php @@ -0,0 +1,24 @@ +title($exception->title ?? null) + ->body($exception->body ?? $exception->getMessage()) + ->color($exception->color ?? 'danger') + ->icon($exception->icon ?? 'tabler-x') + ->danger() + ->send(); + + if ($this->stopPropagation ?? true) { + $stopPropagation(); + } + } +}