RequestPasswordReset mail wip
This commit is contained in:
1 parent
c4685b9412
commit
b73f22fec2
5 files changed
+241
-1
No files matched your search
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages\Auth;
|
||||
|
||||
use App\Notifications\ResetPasswordNotification;
|
||||
use DanHarrin\LivewireRateLimiting\Exceptions\TooManyRequestsException;
|
||||
use Exception;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Auth\PasswordReset\RequestPasswordReset as BaseRequestPasswordReset;
|
||||
use Illuminate\Contracts\Auth\CanResetPassword;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
|
||||
class RequestPasswordReset extends BaseRequestPasswordReset
|
||||
{
|
||||
public function request(): void
|
||||
{
|
||||
try {
|
||||
$this->rateLimit(2);
|
||||
} catch (TooManyRequestsException $exception) {
|
||||
Notification::make()
|
||||
->title(__('filament-panels::pages/auth/password-reset/request-password-reset.notifications.throttled.title', [
|
||||
'seconds' => $exception->secondsUntilAvailable,
|
||||
'minutes' => ceil($exception->secondsUntilAvailable / 60),
|
||||
]))
|
||||
->body(array_key_exists('body', __('filament-panels::pages/auth/password-reset/request-password-reset.notifications.throttled') ?: []) ? __('filament-panels::pages/auth/password-reset/request-password-reset.notifications.throttled.body', [
|
||||
'seconds' => $exception->secondsUntilAvailable,
|
||||
'minutes' => ceil($exception->secondsUntilAvailable / 60),
|
||||
]) : null)
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$data = $this->form->getState();
|
||||
$status = Password::broker(Filament::getAuthPasswordBroker())->sendResetLink(
|
||||
$data,
|
||||
function (CanResetPassword $user, string $token): void {
|
||||
if (! method_exists($user, 'notify')) {
|
||||
$userClass = $user::class;
|
||||
throw new Exception("Model [{$userClass}] does not have a [notify()] method.");
|
||||
}
|
||||
|
||||
$notification = new ResetPasswordNotification($token);
|
||||
$user->notify($notification);
|
||||
},
|
||||
);
|
||||
|
||||
if ($status !== Password::RESET_LINK_SENT) {
|
||||
Notification::make()
|
||||
->title(__($status))
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->title(__($status))
|
||||
->success()
|
||||
->send();
|
||||
|
||||
$this->form->fill();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user