Skip to content

Commit

Permalink
Merge pull request #16 from LibreSign/chore/make-possible-enable-user…
Browse files Browse the repository at this point in the history
…s-when-try-to-create-group

chore: make possible enable users when try to create group
  • Loading branch information
vitormattos authored Dec 6, 2024
2 parents a58d9d5 + 304cc32 commit a3e9959
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions lib/Controller/AdminGroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ private function addSubAdmin(IUser $user, IGroup $group): void {
}

private function createUser($userId, $displayName, $email): IUser {
$user = $this->userManager->get($userId);
if ($user instanceof IUser) {
return $user;
}
$passwordEvent = new GenerateSecurePasswordEvent();
$this->eventDispatcher->dispatchTyped($passwordEvent);
$password = $passwordEvent->getPassword() ?? $this->secureRandom->generate(20);
Expand Down Expand Up @@ -194,15 +198,22 @@ private function addGroup(string $groupid, string $displayname = ''): IGroup {
throw new OCSException('Invalid group name', 101);
}
// Check if it exists
if ($this->groupManager->groupExists($groupid)) {
throw new OCSException('group exists', 102);
$group = $this->groupManager->get($groupid);
if ($group instanceof IGroup) {
$users = $group->getUsers();
foreach ($users as $user) {
$user->setEnabled(true);
}
} else {
$group = $this->groupManager->createGroup($groupid);
}
$group = $this->groupManager->createGroup($groupid);
if ($group === null) {
throw new OCSException('Not supported by backend', 103);
}
if ($displayname !== '') {
$group->setDisplayName($displayname);
if ($group->getDisplayName() !== $displayname) {
$group->setDisplayName($displayname);
}
}
return $group;
}
Expand Down

0 comments on commit a3e9959

Please sign in to comment.