51 lines
2.1 KiB
PHP
51 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Pages\Auth;
|
|
|
|
use App\Filament\Support\CheerfulNotification;
|
|
use DanHarrin\LivewireRateLimiting\Exceptions\TooManyRequestsException;
|
|
use Filament\Actions\Action;
|
|
use Filament\Auth\Pages\EmailVerification\EmailVerificationPrompt;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Support\Enums\Width;
|
|
|
|
class EmailVerification extends EmailVerificationPrompt
|
|
{
|
|
public function getMaxContentWidth(): Width
|
|
{
|
|
return Width::ExtraLarge;
|
|
}
|
|
|
|
public function resendNotificationAction(): Action
|
|
{
|
|
return Action::make('resendNotification')
|
|
->link()
|
|
->label(__('filament-panels::auth/pages/email-verification/email-verification-prompt.actions.resend_notification.label').'.')
|
|
->size('sm')
|
|
->action(function (): void {
|
|
try {
|
|
$this->rateLimit(2);
|
|
} catch (TooManyRequestsException $exception) {
|
|
$this->getRateLimitedNotification($exception)?->send();
|
|
|
|
return;
|
|
}
|
|
|
|
$this->sendEmailVerificationNotification($this->getVerifiable());
|
|
|
|
CheerfulNotification::success(
|
|
CheerfulNotification::getMessage('Mail Meluncur! 📧🚀', 'Email Terkirim'),
|
|
CheerfulNotification::getMessage('Tautan verifikasi baru sudah dikirim ke alamat surelmu. Cek inbox (atau spam) ya! 😉✨', 'Tautan verifikasi baru telah dikirimkan ke alamat email Anda. Silakan periksa kotak masuk atau spam.')
|
|
)->send();
|
|
});
|
|
}
|
|
|
|
protected function getRateLimitedNotification(TooManyRequestsException $exception): ?Notification
|
|
{
|
|
return CheerfulNotification::danger(
|
|
CheerfulNotification::getMessage('Pelan-pelan ya ⏳', 'Terlalu Banyak Permintaan'),
|
|
CheerfulNotification::getMessage('Permintaan terlalu sering. Tunggu sebentar lalu coba lagi dalam '.$exception->secondsUntilAvailable.' detik.', 'Anda telah melakukan terlalu banyak permintaan. Silakan coba kembali dalam '.$exception->secondsUntilAvailable.' detik.')
|
|
)->send();
|
|
}
|
|
}
|