37 lines
1.1 KiB
PHP
37 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use Illuminate\Auth\Notifications\VerifyEmail as BaseVerifyEmail;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Support\Facades\URL;
|
|
use Illuminate\Support\Facades\Config;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
class VerifyEmail extends BaseVerifyEmail
|
|
{
|
|
/**
|
|
* Build the mail representation of the notification.
|
|
*
|
|
* @param mixed $notifiable
|
|
* @return \Illuminate\Notifications\Messages\MailMessage
|
|
*/
|
|
public function toMail($notifiable)
|
|
{
|
|
$verificationUrl = $this->verificationUrl($notifiable);
|
|
|
|
// Generate a 6-digit fallback verification code with same TTL as the link
|
|
$ttl = (int) Config::get('auth.verification.expire', 60);
|
|
$code = (string) random_int(100000, 999999);
|
|
Cache::put('email_verify_code:'.$notifiable->getKey(), $code, now()->addMinutes($ttl));
|
|
|
|
return (new MailMessage)
|
|
->subject('Verify Your Email Address')
|
|
->view('emails.verify-email', [
|
|
'url' => $verificationUrl,
|
|
'user' => $notifiable,
|
|
'code' => $code,
|
|
]);
|
|
}
|
|
}
|