41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class TwoFactorFailedNotification extends Notification implements ShouldQueue
|
|
{
|
|
use Queueable;
|
|
|
|
public function __construct(
|
|
public readonly string $ipAddress,
|
|
public readonly string $userAgent,
|
|
public readonly string $occurredAt
|
|
) {}
|
|
|
|
/**
|
|
* @return list<string>
|
|
*/
|
|
public function via(object $notifiable): array
|
|
{
|
|
return ['mail'];
|
|
}
|
|
|
|
public function toMail(object $notifiable): MailMessage
|
|
{
|
|
return (new MailMessage)
|
|
->subject('Failed two-factor authentication attempt')
|
|
->greeting('Hello '.$notifiable->first_name.',')
|
|
->line('A correct password was followed by a failed two-factor authentication attempt.')
|
|
->line("Time: {$this->occurredAt}")
|
|
->line("IP address: {$this->ipAddress}")
|
|
->line("Browser: {$this->userAgent}")
|
|
->line('If this was not you, change your password immediately.')
|
|
->action('Review account security', url('/profile/security'));
|
|
}
|
|
}
|