71 lines
2.5 KiB
PHP
71 lines
2.5 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 Illuminate\Contracts\Auth\MustVerifyEmail;
|
|
|
|
class EmailVerification extends EmailVerificationPrompt
|
|
{
|
|
// protected function sendEmailVerificationNotification(MustVerifyEmail $user): void
|
|
// {
|
|
// try {
|
|
// $this->rateLimit(2);
|
|
// } catch (TooManyRequestsException $exception) {
|
|
// $this->getRateLimitedNotification($exception)?->send();
|
|
|
|
// return;
|
|
// }
|
|
|
|
// if (! $user->hasVerifiedEmail()) {
|
|
// $user->sendEmailVerificationNotification();
|
|
|
|
// CheerfulNotification::success(
|
|
// 'Mail Meluncur! 📧🚀',
|
|
// 'Tautan verifikasi baru sudah dikirim ke alamat surelmu. Cek inbox (atau spam) ya! 😉✨'
|
|
// )->send();
|
|
// } else {
|
|
// CheerfulNotification::success(
|
|
// 'Sudah Aman Kok! ✅',
|
|
// 'Alamat surel sudah terverifikasi sebelumnya. Langsung lanjut aja! 🏎️💨'
|
|
// )->send();
|
|
// }
|
|
// }
|
|
|
|
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(
|
|
'Mail Meluncur! 📧🚀',
|
|
'Tautan verifikasi baru sudah dikirim ke alamat surelmu. Cek inbox (atau spam) ya! 😉✨'
|
|
)->send();
|
|
});
|
|
}
|
|
|
|
protected function getRateLimitedNotification(TooManyRequestsException $exception): ?Notification
|
|
{
|
|
return CheerfulNotification::danger(
|
|
'Pelan-pelan ya ⏳',
|
|
'Permintaan terlalu sering. Tunggu sebentar lalu coba lagi dalam '.$exception->secondsUntilAvailable.' detik.'
|
|
)->send();
|
|
}
|
|
}
|