diff --git a/lib/Controller/ContactpersonenController.php b/lib/Controller/ContactpersonenController.php index 5f093b2d..bda8fc27 100644 --- a/lib/Controller/ContactpersonenController.php +++ b/lib/Controller/ContactpersonenController.php @@ -23,6 +23,7 @@ use OCA\SoftwareCatalog\Service\SoftwareCatalogue\ContactPersonHandler; use OCA\SoftwareCatalog\Service\ContactpersoonService; use OCP\AppFramework\Controller; +use OCP\AppFramework\Http; use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; use OCP\IUserManager; @@ -569,6 +570,19 @@ public function changePassword(string $username, string $newPassword): JSONRespo */ public function updateUserGroups(string $username, array $groups=[]): JSONResponse { + $currentUser = $this->userSession->getUser(); + if ($currentUser === null) { + return new JSONResponse(['message' => 'Not authenticated'], Http::STATUS_UNAUTHORIZED); + } + + // Only admins and org-admins may modify group assignments. + $isAdmin = $this->groupManager->isAdmin($currentUser->getUID()); + $isOrgAdmin = $this->groupManager->isInGroup($currentUser->getUID(), 'gebruik-beheerder') + || $this->groupManager->isInGroup($currentUser->getUID(), 'aanbod-beheerder'); + if ($isAdmin === false && $isOrgAdmin === false) { + return new JSONResponse(['message' => 'Insufficient permissions'], Http::STATUS_FORBIDDEN); + } + try { $user = $this->userManager->get($username); diff --git a/lib/Service/SettingsService.php b/lib/Service/SettingsService.php index 6f029cf2..19c17931 100644 --- a/lib/Service/SettingsService.php +++ b/lib/Service/SettingsService.php @@ -5797,7 +5797,7 @@ function ($org) { */ private function determineOrganisationType(\OCA\OpenRegister\Db\Organisation $organisation): string { - $name = strtolower($organisation->getName() === true); + $name = strtolower($organisation->getName()); if (strpos($name, 'gemeente') !== false) { return 'Gemeente';