Removed unused variables

This commit is contained in:
Charles 2025-11-25 15:48:19 +01:00
parent 52b8ba0a10
commit 9513067ac5
1 changed files with 33 additions and 9 deletions

View File

@ -24,14 +24,13 @@ class UserService
{ {
public const NOT_FOUND = 'Entity not found'; public const NOT_FOUND = 'Entity not found';
private string $profileDirectory;
public function __construct(private readonly EntityManagerInterface $entityManager, public function __construct(private readonly EntityManagerInterface $entityManager,
private readonly Security $security, private readonly Security $security,
string $profileDirectory, private readonly AwsService $awsService private readonly AwsService $awsService
) )
{ {
$this->profileDirectory = $profileDirectory;
} }
/** /**
@ -175,6 +174,7 @@ class UserService
// Use a fixed key (e.g., 0 or 'none') to avoid collisions with real org IDs // Use a fixed key (e.g., 0 or 'none') to avoid collisions with real org IDs
return ['none' => $group]; return ['none' => $group];
} }
//TODO: reset function //TODO: reset function
public function handleProfilePicture(User $user, $picture): void public function handleProfilePicture(User $user, $picture): void
{ {
@ -287,7 +287,7 @@ class UserService
return 'ROLE_' . $role; return 'ROLE_' . $role;
} }
public function revokeUserTokens(String $userIdentifier) public function revokeUserTokens(string $userIdentifier)
{ {
$tokens = $this->entityManager->getRepository(AccessToken::class)->findBy([ $tokens = $this->entityManager->getRepository(AccessToken::class)->findBy([
'userIdentifier' => $userIdentifier, 'userIdentifier' => $userIdentifier,
@ -425,4 +425,28 @@ class UserService
return $isAdmin && !empty($org); return $isAdmin && !empty($org);
} }
/**
* Handle already existing user when creating a user.
* If the user exists but is inactive, reactivate them.
*
* @param User $user
* @param Organizations $organization
* @return void
*/
public function handleExistingUser(User $user, Organizations $organization): void
{
if (!$user->isActive()) {
$user->setIsActive(true);
$this->entityManager->persist($user);
}
$uo = new UsersOrganizations();
$uo->setUsers($user);
$uo->setOrganization($organization);
$uo->setStatut("INVITED");
$uo->setIsActive(false);
$uo->setModifiedAt(new \DateTimeImmutable('now'));
$this->entityManager->persist($uo);
$this->entityManager->flush();
}
} }