Implements attribute active.

This commit is contained in:
Pierre Ozoux 2022-04-29 18:03:57 +02:00
parent ace615aa97
commit d369661b8c
2 changed files with 9 additions and 3 deletions

View file

@ -88,6 +88,8 @@ abstract class ASCIMUser extends ApiController {
throw new SCIMException('User not found', 404); throw new SCIMException('User not found', 404);
} }
$enabled = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'enabled', 'true') === 'true';
return [ return [
'schemas' => ["urn:ietf:params:scim:schemas:core:2.0:User"], 'schemas' => ["urn:ietf:params:scim:schemas:core:2.0:User"],
'id' => $userId, 'id' => $userId,
@ -106,7 +108,7 @@ abstract class ASCIMUser extends ApiController {
] ]
], ],
//'groups' => [], //'groups' => [],
'active' => (bool) $this->config->getUserValue($userId, 'core', 'enabled', 'true') === 'true' 'active' => $enabled
]; ];
} }

View file

@ -157,9 +157,9 @@ class UserController extends ASCIMUser {
* @return SCIMResourceResponse * @return SCIMResourceResponse
* @throws SCIMException * @throws SCIMException
*/ */
public function create( bool $active = true, public function create( bool $active = true,
string $displayName = '', string $displayName = '',
array $emails = [], array $emails = [],
string $userName = ''): SCIMResourceResponse { string $userName = ''): SCIMResourceResponse {
if ($this->userManager->userExists($userName)) { if ($this->userManager->userExists($userName)) {
$this->logger->error('Failed createUser attempt: User already exists.', ['app' => 'SCIMServiceProvider']); $this->logger->error('Failed createUser attempt: User already exists.', ['app' => 'SCIMServiceProvider']);
@ -175,6 +175,7 @@ class UserController extends ASCIMUser {
$newUser->setEMailAddress($email['value']); $newUser->setEMailAddress($email['value']);
} }
} }
$newUser->setEnabled($active);
return new SCIMResourceResponse($this->getSCIMUser($userName)); return new SCIMResourceResponse($this->getSCIMUser($userName));
} catch (SCIMException $e) { } catch (SCIMException $e) {
$this->logger->warning('Failed createUser attempt with SCIMException exeption.', ['app' => 'SCIMServiceProvider']); $this->logger->warning('Failed createUser attempt with SCIMException exeption.', ['app' => 'SCIMServiceProvider']);
@ -207,6 +208,9 @@ class UserController extends ASCIMUser {
$targetUser->setEMailAddress($email['value']); $targetUser->setEMailAddress($email['value']);
} }
} }
if (isset($active)) {
$targetUser->setEnabled($active);
}
return new SCIMResourceResponse($this->getSCIMUser($id)); return new SCIMResourceResponse($this->getSCIMUser($id));
} }