This commit is contained in:
Saufi
2026-06-02 17:35:45 +08:00
commit 4ef99b1f81
148 changed files with 21134 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Actions;
use App\Models\User;
use App\Services\AuditLogService;
class ChangeUserEmailAction
{
public function __construct(private readonly AuditLogService $audit) {}
public function execute(User $user, string $newEmail, ?string $justification = null): void
{
$oldEmail = $user->email;
$user->update([
'email' => $newEmail,
'email_verified_at' => null,
]);
$this->audit->log('user_email_changed', [
'subject_type' => User::class,
'subject_id' => $user->id,
'target_user_id' => $user->id,
'old_values' => ['email' => $oldEmail],
'new_values' => ['email' => $newEmail],
'justification' => $justification,
]);
}
}