From 53b67b23ddae833dee210ec43408a1e601d5779c Mon Sep 17 00:00:00 2001 From: Refringe Date: Sat, 6 Jul 2024 19:14:51 -0400 Subject: [PATCH] Queueable Account Notifications The email verification and password reset notifications are now handled on a queue. --- app/Models/User.php | 18 ++++++++++++++++++ app/Notifications/ResetPassword.php | 25 +++++++++++++++++++++++++ app/Notifications/VerifyEmail.php | 20 ++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 app/Notifications/ResetPassword.php create mode 100644 app/Notifications/VerifyEmail.php diff --git a/app/Models/User.php b/app/Models/User.php index 248fd04..224e5b5 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -2,6 +2,8 @@ namespace App\Models; +use App\Notifications\ResetPassword; +use App\Notifications\VerifyEmail; use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -76,6 +78,22 @@ class User extends Authenticatable implements MustVerifyEmail return Str::lower($this->role?->name) === 'administrator'; } + /** + * Overwritten to instead use the queued version of the VerifyEmail notification. + */ + public function sendEmailVerificationNotification(): void + { + $this->notify(new VerifyEmail); + } + + /** + * Overwritten to instead use the queued version of the ResetPassword notification. + */ + public function sendPasswordResetNotification(#[\SensitiveParameter] $token): void + { + $this->notify(new ResetPassword($token)); + } + protected function casts(): array { return [ diff --git a/app/Notifications/ResetPassword.php b/app/Notifications/ResetPassword.php new file mode 100644 index 0000000..85c4838 --- /dev/null +++ b/app/Notifications/ResetPassword.php @@ -0,0 +1,25 @@ +