
- Added functionality for users to request an email change, including generating a verification code and setting an expiration time. - Implemented methods in the User model to handle email change requests, code validation, and confirmation. - Created a new job to update the user's email in Stripe after confirmation. - Introduced rate limiting for email change requests and verification attempts to prevent abuse. - Added a new notification for email change verification. - Updated the profile component to manage email change requests and verification UI.
44 lines
1.2 KiB
PHP
44 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications\TransactionalEmails;
|
|
|
|
use App\Models\User;
|
|
use App\Notifications\Channels\TransactionalEmailChannel;
|
|
use App\Notifications\CustomEmailNotification;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
class EmailChangeVerification extends CustomEmailNotification
|
|
{
|
|
public function via(): array
|
|
{
|
|
return [TransactionalEmailChannel::class];
|
|
}
|
|
|
|
public function __construct(
|
|
public User $user,
|
|
public string $verificationCode,
|
|
public string $newEmail,
|
|
public Carbon $expiresAt,
|
|
public bool $isTransactionalEmail = true
|
|
) {
|
|
$this->onQueue('high');
|
|
}
|
|
|
|
public function toMail(): MailMessage
|
|
{
|
|
// Use the configured expiry minutes value
|
|
$expiryMinutes = config('constants.email_change.verification_code_expiry_minutes', 10);
|
|
|
|
$mail = new MailMessage;
|
|
$mail->subject('Coolify: Verify Your New Email Address');
|
|
$mail->view('emails.email-change-verification', [
|
|
'newEmail' => $this->newEmail,
|
|
'verificationCode' => $this->verificationCode,
|
|
'expiryMinutes' => $expiryMinutes,
|
|
]);
|
|
|
|
return $mail;
|
|
}
|
|
}
|