Skip to content

Commit

Permalink
Update original email
Browse files Browse the repository at this point in the history
  • Loading branch information
LoganTFox committed Mar 28, 2024
1 parent a9793e5 commit a5a8105
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Listeners/SendSecurityNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function handle(SecureFieldsUpdated $event): void
{
$notificationClass = config('security-notifications.notifications.secure_fields');

Notification::route('mail', $event->model->getSecurityNotificationsEmail())
Notification::route('mail', $event->model->original_email)
->notify(new $notificationClass($event->fields));
}
}
7 changes: 2 additions & 5 deletions src/Traits/Securable.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,14 @@ trait Securable
'password',
];

public function getSecurityNotificationsEmail(): string
{
return $this->getOriginal('email');
}

public static function bootSecurable(): void
{
if (config('security-notifications.send_notifications')) {
static::updated(function (Model $model) {
$changedSecureFields = collect($model->getChanges())->only(self::$secureFields);

$model->setAttribute('original_email', $model->getOriginal('email') ?? $model->getAttribute('email'));

if ($changedSecureFields->count()) {
event(new SecureFieldsUpdated($model, $changedSecureFields->toArray()));
}
Expand Down

0 comments on commit a5a8105

Please sign in to comment.