| null */ public ?array $data = []; public function mount(): void { if (Filament::auth()->check()) { redirect()->intended(Filament::getUrl()); } $this->form->fill(); } 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); $notification->url = Filament::getResetPasswordUrl($token, $user); $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(); } public function form(Form $form): Form { return $form; } /** * @return array */ protected function getForms(): array { return [ 'form' => $this->form( $this->makeForm() ->schema([ $this->getEmailFormComponent(), ]) ->statePath('data'), ), ]; } protected function getEmailFormComponent(): Component { return TextInput::make('email') ->label(__('filament-panels::pages/auth/password-reset/request-password-reset.form.email.label')) ->email() ->required() ->autocomplete() ->autofocus(); } public function loginAction(): Action { return Action::make('login') ->link() ->label(__('filament-panels::pages/auth/password-reset/request-password-reset.actions.login.label')) ->icon(match (__('filament-panels::layout.direction')) { 'rtl' => 'heroicon-m-arrow-right', default => 'heroicon-m-arrow-left', }) ->url(filament()->getLoginUrl()); } public function getTitle(): string | Htmlable { return __('filament-panels::pages/auth/password-reset/request-password-reset.title'); } public function getHeading(): string | Htmlable { return __('filament-panels::pages/auth/password-reset/request-password-reset.heading'); } /** * @return array */ protected function getFormActions(): array { return [ $this->getRequestFormAction(), ]; } protected function getRequestFormAction(): Action { return Action::make('request') ->label(__('filament-panels::pages/auth/password-reset/request-password-reset.form.actions.request.label')) ->submit('request'); } protected function hasFullWidthFormActions(): bool { return true; } }