From cc6f90b1077089fe13713c7c546d4f384760c475 Mon Sep 17 00:00:00 2001 From: Pierre Ozoux Date: Mon, 2 May 2022 15:24:27 +0200 Subject: [PATCH] Fixes wrong error code. --- lib/Controller/GroupController.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/Controller/GroupController.php b/lib/Controller/GroupController.php index 044e3fe..fcad879 100644 --- a/lib/Controller/GroupController.php +++ b/lib/Controller/GroupController.php @@ -145,11 +145,11 @@ class GroupController extends ASCIMGroup { public function create( string $displayName = '', array $members = []): SCIMJSONResponse { - $id=urldecode($displayName); + $id = urlencode($displayName); // Validate name if (empty($id)) { $this->logger->error('Group name not supplied', ['app' => 'provisioning_api']); - return new SCIMErrorResponse(['message' => 'Invalid group name'], 101); + return new SCIMErrorResponse(['message' => 'Invalid group name'], 400); } // Check if it exists if ($this->groupManager->groupExists($id)) { @@ -159,10 +159,9 @@ class GroupController extends ASCIMGroup { if ($group === null) { return new SCIMErrorResponse(['message' => 'Not supported by backend'], 103); } - if ($displayname !== '') { - $group->setDisplayName($displayName); - } + $group->setDisplayName($displayName); foreach ($members as $member) { + $this->logger->error('Group name not supplied' . $member['value'], ['app' => 'provisioning_api']); $targetUser = $this->userManager->get($member['value']); $group->addUser($targetUser); } @@ -184,6 +183,9 @@ class GroupController extends ASCIMGroup { string $displayName = '', array $members = []): SCIMJSONResponse { $group = $this->groupManager->get($id); + if (!$this->groupManager->groupExists($id)) { + return new SCIMErrorResponse(['message' => 'Group not found'], 404); + } foreach ($members as $member) { $targetUser = $this->userManager->get($member['value']); $group->addUser($targetUser);