Removed unused variables
This commit is contained in:
parent
52b8ba0a10
commit
9513067ac5
|
|
@ -24,14 +24,13 @@ class UserService
|
|||
{
|
||||
|
||||
public const NOT_FOUND = 'Entity not found';
|
||||
private string $profileDirectory;
|
||||
|
||||
public function __construct(private readonly EntityManagerInterface $entityManager,
|
||||
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
|
||||
return ['none' => $group];
|
||||
}
|
||||
|
||||
//TODO: reset function
|
||||
public function handleProfilePicture(User $user, $picture): void
|
||||
{
|
||||
|
|
@ -184,10 +184,10 @@ class UserService
|
|||
// Create custom filename: userNameUserSurname_ddmmyyhhmmss
|
||||
$customFilename = $user->getName() . $user->getSurname() . '_' . date('dmyHis') . '.' . $extension;
|
||||
// $customFilename = $user->getName() . $user->getSurname() . "." .$extension;
|
||||
try{
|
||||
$this->awsService->PutDocObj($_ENV['S3_PORTAL_BUCKET'], $picture, $customFilename , $extension, 'profile/');
|
||||
try {
|
||||
$this->awsService->PutDocObj($_ENV['S3_PORTAL_BUCKET'], $picture, $customFilename, $extension, 'profile/');
|
||||
|
||||
$user->setPictureUrl('profile/'.$customFilename);
|
||||
$user->setPictureUrl('profile/' . $customFilename);
|
||||
} catch (FileException $e) {
|
||||
// Handle upload error
|
||||
throw new FileException('File upload failed: ' . $e->getMessage());
|
||||
|
|
@ -287,7 +287,7 @@ class UserService
|
|||
return 'ROLE_' . $role;
|
||||
}
|
||||
|
||||
public function revokeUserTokens(String $userIdentifier)
|
||||
public function revokeUserTokens(string $userIdentifier)
|
||||
{
|
||||
$tokens = $this->entityManager->getRepository(AccessToken::class)->findBy([
|
||||
'userIdentifier' => $userIdentifier,
|
||||
|
|
@ -330,7 +330,7 @@ class UserService
|
|||
return $formatted;
|
||||
}
|
||||
|
||||
public function generatePasswordToken(User $user, int $orgId): string
|
||||
public function generatePasswordToken(User $user, int $orgId): string
|
||||
{
|
||||
$orgString = "o" . $orgId . "@";
|
||||
$token = $orgString . bin2hex(random_bytes(32));
|
||||
|
|
@ -349,7 +349,7 @@ class UserService
|
|||
return true;
|
||||
}
|
||||
|
||||
public function isPasswordStrong(string $newPassword):bool
|
||||
public function isPasswordStrong(string $newPassword): bool
|
||||
{
|
||||
$pewpew = 0;
|
||||
if (preg_match('/\w/', $newPassword)) { //Find any alphabetical letter (a to Z) and digit (0 to 9)
|
||||
|
|
@ -425,4 +425,28 @@ class UserService
|
|||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue