diff --git a/lib/Controller/AdminGroupController.php b/lib/Controller/AdminGroupController.php index c553d5f..afc8541 100644 --- a/lib/Controller/AdminGroupController.php +++ b/lib/Controller/AdminGroupController.php @@ -165,14 +165,13 @@ 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); + if (!$user instanceof IUser) { + $passwordEvent = new GenerateSecurePasswordEvent(); + $this->eventDispatcher->dispatchTyped($passwordEvent); + $password = $passwordEvent->getPassword() ?? $this->secureRandom->generate(20); - $user = $this->userManager->createUser($userId, $password); + $user = $this->userManager->createUser($userId, $password); + } if ($displayName !== '') { try {