fix(admin): reject customer email on operator account update; do not claim mail delivery on dispatch

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
feat/portal-design
nexxo 2026-07-25 15:58:24 +02:00
parent d68d8e1f25
commit e5c74c6bdd
2 changed files with 13 additions and 1 deletions

View File

@ -129,10 +129,13 @@ class Maintenance extends Component
['email' => $customer->email],
);
if ($delivery->wasRecentlyCreated) {
// The ledger row (created here) is the idempotency marker so we
// queue at most once per customer. sent_at stays null until the
// mail is actually delivered — a MessageSent listener could stamp
// it later; we never claim delivery merely on dispatch.
Mail::to($customer->email)
->locale($customer->locale ?: config('app.locale'))
->queue(new MaintenanceAnnouncementMail($window, $customer));
$delivery->update(['sent_at' => now()]);
}
}
}

View File

@ -49,6 +49,15 @@ class Settings extends Component
'name' => 'required|string|max:255',
'email' => 'required|email|max:255|unique:users,email,'.$user->id,
]);
// An operator email must never collide with a customer's — that would
// block the customer from ever obtaining a portal login (ensureUser).
if (Customer::query()->where('email', $data['email'])->exists()) {
$this->addError('email', __('admin_settings.is_customer'));
return;
}
$user->update($data);
$this->dispatch('notify', message: __('admin_settings.account_saved'));
}