Skip to content

Commit

Permalink
updated user filters for status deleted
Browse files Browse the repository at this point in the history
Signed-off-by: bidi <[email protected]>
  • Loading branch information
bidi47 committed Dec 11, 2024
1 parent a987e03 commit d332f71
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
10 changes: 0 additions & 10 deletions src/User/src/Controller/AccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ public function activateAction(): ResponseInterface
return new RedirectResponse($this->router->generateUri('user', ['action' => 'login']));
}

if ($user->isDeleted()) {
$this->messenger->addError(Message::ACCOUNT_NOT_FOUND, 'user-login');
return new RedirectResponse($this->router->generateUri('user', ['action' => 'login']));
}

if ($user->isActive()) {
$this->messenger->addError(Message::USER_ALREADY_ACTIVATED, 'user-login');
return new RedirectResponse($this->router->generateUri('user', ['action' => 'login']));
Expand Down Expand Up @@ -101,11 +96,6 @@ public function unregisterAction(): ResponseInterface
return new RedirectResponse($this->router->generateUri('user', ['action' => 'login']));
}

if ($user->isDeleted()) {
$this->messenger->addError(Message::USER_ALREADY_DEACTIVATED, 'user-login');
return new RedirectResponse($this->router->generateUri('user', ['action' => 'login']));
}

if (! $user->isPending()) {
$this->messenger->addError(Message::USER_UNREGISTER_STATUS, 'user-login');
return new RedirectResponse($this->router->generateUri('user', ['action' => 'login']));
Expand Down
26 changes: 14 additions & 12 deletions src/User/src/Service/UserService.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,14 @@ public function updateUser(User $user, array $data = []): User
public function deleteUser(User $user): User
{
$user->setStatus(UserStatusEnum::Deleted);

if ($user->isDeleted()) {
$placeholder = $this->getAnonymousPlaceholder();

// make user anonymous
$user
->setIdentity($placeholder . $this->config['userAnonymizeAppend'])
->getDetail()
->setFirstName($placeholder)
->setLastName($placeholder);
}
$placeholder = $this->getAnonymousPlaceholder();

// make user anonymous
$user
->setIdentity($placeholder . $this->config['userAnonymizeAppend'])
->getDetail()
->setFirstName($placeholder)
->setLastName($placeholder);
return $this->userRepository->saveUser($user);
}

Expand Down Expand Up @@ -288,7 +285,12 @@ public function findOneBy(array $params = []): ?User
return null;
}

return $this->userRepository->findOneBy($params);
$user = $this->userRepository->findOneBy($params);
if ($user->isDeleted()) {
return null;
}

return $user;
}

public function activateUser(User $user): User
Expand Down

0 comments on commit d332f71

Please sign in to comment.