major update
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace MintyPHP\Service\Audit;
|
||||
|
||||
use MintyPHP\Domain\Taxonomy\UserLifecycleAction;
|
||||
use MintyPHP\Domain\Taxonomy\UserLifecycleStatus;
|
||||
use MintyPHP\Domain\Taxonomy\UserLifecycleTriggerType;
|
||||
use MintyPHP\Repository\Audit\UserLifecycleAuditRepository;
|
||||
use MintyPHP\Support\Crypto;
|
||||
|
||||
@@ -49,13 +52,13 @@ class UserLifecycleAuditService
|
||||
array $policy,
|
||||
?int $actorUserId,
|
||||
array $targetUser,
|
||||
string $status = 'success',
|
||||
string $status = UserLifecycleStatus::Success->value,
|
||||
?string $reasonCode = null
|
||||
): bool {
|
||||
try {
|
||||
return $this->userLifecycleAuditRepository->create($this->buildBaseRow(
|
||||
$runUuid,
|
||||
'deactivate',
|
||||
UserLifecycleAction::Deactivate->value,
|
||||
$triggerType,
|
||||
$status,
|
||||
$reasonCode,
|
||||
@@ -83,9 +86,9 @@ class UserLifecycleAuditService
|
||||
}
|
||||
$row = $this->buildBaseRow(
|
||||
$runUuid,
|
||||
'delete',
|
||||
UserLifecycleAction::Delete->value,
|
||||
$triggerType,
|
||||
'success',
|
||||
UserLifecycleStatus::Success->value,
|
||||
null,
|
||||
$policy,
|
||||
$actorUserId,
|
||||
@@ -110,9 +113,9 @@ class UserLifecycleAuditService
|
||||
try {
|
||||
return $this->userLifecycleAuditRepository->create($this->buildBaseRow(
|
||||
$runUuid,
|
||||
'delete',
|
||||
UserLifecycleAction::Delete->value,
|
||||
$triggerType,
|
||||
'failed',
|
||||
UserLifecycleStatus::Failed->value,
|
||||
$reasonCode,
|
||||
$policy,
|
||||
$actorUserId,
|
||||
@@ -129,13 +132,13 @@ class UserLifecycleAuditService
|
||||
array $policy,
|
||||
?int $actorUserId,
|
||||
array $targetUser,
|
||||
string $status = 'success',
|
||||
string $status = UserLifecycleStatus::Success->value,
|
||||
?string $reasonCode = null
|
||||
): bool {
|
||||
try {
|
||||
return $this->userLifecycleAuditRepository->create($this->buildBaseRow(
|
||||
$runUuid,
|
||||
'restore',
|
||||
UserLifecycleAction::Restore->value,
|
||||
$triggerType,
|
||||
$status,
|
||||
$reasonCode,
|
||||
@@ -167,6 +170,11 @@ class UserLifecycleAuditService
|
||||
return $this->userLifecycleAuditRepository->find($id);
|
||||
}
|
||||
|
||||
public function filterOptions(int $limit = 200): array
|
||||
{
|
||||
return $this->userLifecycleAuditRepository->listFilterOptions($limit);
|
||||
}
|
||||
|
||||
public function findDeleteEventForRestore(int $id, bool $forUpdate = false): ?array
|
||||
{
|
||||
return $this->userLifecycleAuditRepository->findDeleteEventForRestore($id, $forUpdate);
|
||||
@@ -211,14 +219,9 @@ class UserLifecycleAuditService
|
||||
?int $actorUserId,
|
||||
array $targetUser
|
||||
): array {
|
||||
$triggerType = strtolower(trim($triggerType));
|
||||
if (!in_array($triggerType, ['manual', 'cron', 'system'], true)) {
|
||||
$triggerType = 'system';
|
||||
}
|
||||
$status = strtolower(trim($status));
|
||||
if (!in_array($status, ['success', 'skipped', 'failed'], true)) {
|
||||
$status = 'failed';
|
||||
}
|
||||
$action = UserLifecycleAction::normalizeOr($action, UserLifecycleAction::Deactivate)->value;
|
||||
$triggerType = UserLifecycleTriggerType::normalizeOr($triggerType, UserLifecycleTriggerType::System)->value;
|
||||
$status = UserLifecycleStatus::normalizeOr($status, UserLifecycleStatus::Failed)->value;
|
||||
|
||||
return [
|
||||
'run_uuid' => trim($runUuid),
|
||||
|
||||
Reference in New Issue
Block a user