Feat: Pending Email Change Updates, Moving Mailables to core
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Core\Auth\Events;
|
||||
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
|
||||
/**
|
||||
* Dispatched by Customer\Services\CustomerEmailChangeService::confirm()
|
||||
* once a login-email change actually takes effect — $oldEmail is what the
|
||||
* account's login used to be, already overwritten on $user by the time
|
||||
* this fires.
|
||||
*/
|
||||
class UserEmailChanged
|
||||
{
|
||||
public function __construct(
|
||||
public readonly Authenticatable $user,
|
||||
public readonly string $oldEmail,
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Core\Auth\Mail;
|
||||
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
|
||||
/**
|
||||
* Sent to the NEW address a shopper is trying to switch their login email
|
||||
* to (Customer\Services\CustomerEmailChangeService::request()) — proves
|
||||
* they can actually receive mail there before the switch takes effect.
|
||||
* View overridable per-app the same way UserOtpMail's is (resources/
|
||||
* views/vendor/core/auth/mail/email-change-code.blade.php).
|
||||
*/
|
||||
class EmailChangeCodeMail extends Mailable
|
||||
{
|
||||
public function __construct(
|
||||
public readonly string $code,
|
||||
) {}
|
||||
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(subject: 'Confirm your new email address');
|
||||
}
|
||||
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(view: 'core::auth.mail.email-change-code');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Core\Auth\Mail;
|
||||
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
|
||||
/**
|
||||
* Sent to the OLD address once a login-email change actually takes
|
||||
* effect (Customer\Services\CustomerEmailChangeService::confirm()) — lets
|
||||
* the previous owner notice if someone else changed it from a hijacked
|
||||
* session. Shows the new address masked (first character + domain only),
|
||||
* never the full new address — this notice's whole point is alerting the
|
||||
* OLD owner, not handing them the new address outright. View overridable
|
||||
* per-app the same way UserOtpMail's is (resources/views/vendor/core/
|
||||
* auth/mail/email-changed-notice.blade.php).
|
||||
*/
|
||||
class EmailChangedNoticeMail extends Mailable
|
||||
{
|
||||
public readonly string $maskedEmail;
|
||||
|
||||
public function __construct(string $newEmail)
|
||||
{
|
||||
[$local, $domain] = explode('@', $newEmail, 2);
|
||||
|
||||
$this->maskedEmail = mb_substr($local, 0, 1).'•••@'.$domain;
|
||||
}
|
||||
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(subject: 'Your account email was changed');
|
||||
}
|
||||
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(view: 'core::auth.mail.email-changed-notice');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user