Corrected UO link deactivation logic
This commit is contained in:
parent
f09dd20d2b
commit
7da97b0d02
|
|
@ -307,7 +307,7 @@ class UserController extends AbstractController
|
||||||
}
|
}
|
||||||
$user->setIsActive(false);
|
$user->setIsActive(false);
|
||||||
$user->setModifiedAt(new \DateTimeImmutable('now'));
|
$user->setModifiedAt(new \DateTimeImmutable('now'));
|
||||||
$this->userOrganizationService->deactivateAllUserOrganizationLinks($user, $actingUser);
|
$this->userOrganizationService->deactivateAllUserOrganizationLinks($actingUser, $user);
|
||||||
if ($this->userService->isUserConnected($user->getUserIdentifier())) {
|
if ($this->userService->isUserConnected($user->getUserIdentifier())) {
|
||||||
$this->userService->revokeUserTokens($user->getUserIdentifier());
|
$this->userService->revokeUserTokens($user->getUserIdentifier());
|
||||||
}
|
}
|
||||||
|
|
@ -429,7 +429,7 @@ class UserController extends AbstractController
|
||||||
}
|
}
|
||||||
$user->setIsActive(false);
|
$user->setIsActive(false);
|
||||||
$user->setModifiedAt(new \DateTimeImmutable('now'));
|
$user->setModifiedAt(new \DateTimeImmutable('now'));
|
||||||
$this->userOrganizationService->deactivateAllUserOrganizationLinks($user, $actingUser);
|
$this->userOrganizationService->deactivateAllUserOrganizationLinks($actingUser, $user);
|
||||||
$user->setIsDeleted(true);
|
$user->setIsDeleted(true);
|
||||||
if ($this->userService->isUserConnected($user)) {
|
if ($this->userService->isUserConnected($user)) {
|
||||||
$this->userService->revokeUserTokens($user->getUserIdentifier());
|
$this->userService->revokeUserTokens($user->getUserIdentifier());
|
||||||
|
|
|
||||||
|
|
@ -26,16 +26,21 @@ readonly class UserOrganizationService
|
||||||
/**
|
/**
|
||||||
* Deactive all user organization links.
|
* Deactive all user organization links.
|
||||||
*
|
*
|
||||||
* @param User $user
|
|
||||||
* @param User $actingUser
|
* @param User $actingUser
|
||||||
|
* @param User|null $user
|
||||||
|
* @param Organizations|null $organizations
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function deactivateAllUserOrganizationLinks(User $actingUser, User $user = null, Organizations $organizations = null): void{
|
public function deactivateAllUserOrganizationLinks(User $actingUser, User $user = null, Organizations $organizations = null): void{
|
||||||
|
//If user provided, get all UO links for that user that are active
|
||||||
if($user !== null) {
|
if($user !== null) {
|
||||||
$uos = $this->entityManager->getRepository(UsersOrganizations::class)->findBy(['users' => $user, 'isActive' => true]);
|
$uos = $this->entityManager->getRepository(UsersOrganizations::class)->findBy(['users' => $user, 'isActive' => true]);
|
||||||
}elseif($organizations !== null){
|
}
|
||||||
|
// if organization provided, get all UO links for that organization that are active
|
||||||
|
elseif($organizations !== null){
|
||||||
$uos = $this->entityManager->getRepository(UsersOrganizations::class)->findBy(['organization' => $organizations, 'isActive' => true]);
|
$uos = $this->entityManager->getRepository(UsersOrganizations::class)->findBy(['organization' => $organizations, 'isActive' => true]);
|
||||||
}
|
}
|
||||||
|
//deactivate all UO links
|
||||||
foreach ($uos as $uo) {
|
foreach ($uos as $uo) {
|
||||||
$this->userOrganizationAppService->deactivateAllUserOrganizationsAppLinks($uo);
|
$this->userOrganizationAppService->deactivateAllUserOrganizationsAppLinks($uo);
|
||||||
$uo->setIsActive(false);
|
$uo->setIsActive(false);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue