feat: add user editing password reset and deletion
This commit is contained in:
@@ -53,6 +53,7 @@ final class UserAdminService
|
||||
$result = ($this->users ?? new UserRecord())->validate($input);
|
||||
$existing = $existingUsers[array_search($id, array_map(static fn($row) => is_array($row) ? (int)($row['id'] ?? 0) : 0, $existingUsers), true)] ?? [];
|
||||
if ($this->isProtectedAdministrator(['id' => $id, ...$existing]) && array_key_exists('role_id', $input) && (int)$input['role_id'] !== 1) $result['errors']['role_id'] = 'The protected Administrator account cannot be reassigned.';
|
||||
if ($this->isProtectedAdministrator(['id' => $id, ...$existing]) && array_key_exists('is_active', $input) && !$this->asBool($input['is_active'])) $result['errors']['is_active'] = 'The protected Administrator account cannot be deactivated.';
|
||||
$email = $result['email'] ?? '';
|
||||
if (is_string($email) && $email !== '' && $this->hasDuplicateEmail($email, $existingUsers, $id)) {
|
||||
$result['errors']['email'] = 'Email address is already in use.';
|
||||
|
||||
Reference in New Issue
Block a user