From c891ef05e79976fa7fa4a63cbaf5799aac6d5e7d Mon Sep 17 00:00:00 2001 From: Lupu Gheorghe Date: Mon, 23 Sep 2024 13:10:18 +0300 Subject: [PATCH] small improvments --- .../Actions/ResetPasswordAction.php | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/app/Filament/Resources/UserResource/Actions/ResetPasswordAction.php b/app/Filament/Resources/UserResource/Actions/ResetPasswordAction.php index ac35c9c..383c10f 100644 --- a/app/Filament/Resources/UserResource/Actions/ResetPasswordAction.php +++ b/app/Filament/Resources/UserResource/Actions/ResetPasswordAction.php @@ -10,6 +10,7 @@ use Illuminate\Support\Facades\Password; use Illuminate\Support\Facades\RateLimiter; +const HOUR_IN_SECONDS = 3600; class ResetPasswordAction extends Action { public static function getDefaultName(): ?string @@ -36,17 +37,23 @@ protected function setUp(): void return; } - RateLimiter::increment($key, 3600); + RateLimiter::increment($key, HOUR_IN_SECONDS); $response = Password::broker(config('filament-breezy.reset_broker', config('auth.defaults.passwords')))->sendResetLink(['email' => $record->email]); - if ($response == Password::RESET_LINK_SENT) { - Notification::make()->title(__('filament-breezy::default.reset_password.notification_success'))->success()->send(); - } else { - Notification::make()->title(match ($response) { - 'passwords.throttled' => __('passwords.throttled'), - 'passwords.user' => __('passwords.user') - })->danger()->send(); + if ($response === Password::RESET_LINK_SENT) { + Notification::make() + ->title(__('filament-breezy::default.reset_password.notification_success')) + ->success() + ->send(); + + return; } + Notification::make()->title(match ($response) { + 'passwords.throttled' => __('passwords.throttled'), + 'passwords.user' => __('passwords.user') + }) + ->danger() + ->send(); }); }