Initialer Laravel Commit für BetiX
This commit is contained in:
36
app/Notifications/VerifyEmail.php
Normal file
36
app/Notifications/VerifyEmail.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user