mirror of
https://github.com/sp-tarkov/forge.git
synced 2025-02-13 04:30:41 -05:00
Queueable Account Notifications
The email verification and password reset notifications are now handled on a queue.
This commit is contained in:
parent
33ad76849e
commit
53b67b23dd
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Notifications\ResetPassword;
|
||||||
|
use App\Notifications\VerifyEmail;
|
||||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
@ -76,6 +78,22 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||||||
return Str::lower($this->role?->name) === 'administrator';
|
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
|
protected function casts(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
25
app/Notifications/ResetPassword.php
Normal file
25
app/Notifications/ResetPassword.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Notifications;
|
||||||
|
|
||||||
|
use Illuminate\Auth\Notifications\ResetPassword as OriginalResetPassword;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class exists solely to make the original notification queueable.
|
||||||
|
*/
|
||||||
|
class ResetPassword extends OriginalResetPassword implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
|
||||||
|
public function __construct($token)
|
||||||
|
{
|
||||||
|
parent::__construct($token);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toArray(object $notifiable): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
20
app/Notifications/VerifyEmail.php
Normal file
20
app/Notifications/VerifyEmail.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Notifications;
|
||||||
|
|
||||||
|
use Illuminate\Auth\Notifications\VerifyEmail as OriginalVerifyEmail;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class exists solely to make the original notification queueable.
|
||||||
|
*/
|
||||||
|
class VerifyEmail extends OriginalVerifyEmail implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
|
||||||
|
public function toArray(object $notifiable): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user