From d369661b8c09cf6187bac6b302fd647f08105e8b Mon Sep 17 00:00:00 2001 From: Pierre Ozoux Date: Fri, 29 Apr 2022 18:03:57 +0200 Subject: [PATCH] Implements attribute active. --- lib/Controller/ASCIMUser.php | 4 +++- lib/Controller/UserController.php | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/Controller/ASCIMUser.php b/lib/Controller/ASCIMUser.php index e592731..434256d 100644 --- a/lib/Controller/ASCIMUser.php +++ b/lib/Controller/ASCIMUser.php @@ -88,6 +88,8 @@ abstract class ASCIMUser extends ApiController { throw new SCIMException('User not found', 404); } + $enabled = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'enabled', 'true') === 'true'; + return [ 'schemas' => ["urn:ietf:params:scim:schemas:core:2.0:User"], 'id' => $userId, @@ -106,7 +108,7 @@ abstract class ASCIMUser extends ApiController { ] ], //'groups' => [], - 'active' => (bool) $this->config->getUserValue($userId, 'core', 'enabled', 'true') === 'true' + 'active' => $enabled ]; } diff --git a/lib/Controller/UserController.php b/lib/Controller/UserController.php index c7cd3c6..d9708e5 100644 --- a/lib/Controller/UserController.php +++ b/lib/Controller/UserController.php @@ -157,9 +157,9 @@ class UserController extends ASCIMUser { * @return SCIMResourceResponse * @throws SCIMException */ - public function create( bool $active = true, + public function create( bool $active = true, string $displayName = '', - array $emails = [], + array $emails = [], string $userName = ''): SCIMResourceResponse { if ($this->userManager->userExists($userName)) { $this->logger->error('Failed createUser attempt: User already exists.', ['app' => 'SCIMServiceProvider']); @@ -175,6 +175,7 @@ class UserController extends ASCIMUser { $newUser->setEMailAddress($email['value']); } } + $newUser->setEnabled($active); return new SCIMResourceResponse($this->getSCIMUser($userName)); } catch (SCIMException $e) { $this->logger->warning('Failed createUser attempt with SCIMException exeption.', ['app' => 'SCIMServiceProvider']); @@ -207,6 +208,9 @@ class UserController extends ASCIMUser { $targetUser->setEMailAddress($email['value']); } } + if (isset($active)) { + $targetUser->setEnabled($active); + } return new SCIMResourceResponse($this->getSCIMUser($id)); }