diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-02-27 22:03:40 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-02-27 22:03:40 +0100 |
commit | fbeaacdf1b3a24043fb0616c14e18b26f4308dd9 (patch) | |
tree | c118988c11091ab5ef6f66e32636a08ed66eb983 /apps/provisioning_api/lib | |
parent | 24b58a76831b5183c6daafef32a1a6e333afa877 (diff) | |
download | nextcloud-server-fbeaacdf1b3a24043fb0616c14e18b26f4308dd9.tar.gz nextcloud-server-fbeaacdf1b3a24043fb0616c14e18b26f4308dd9.zip |
Fix tests
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/provisioning_api/lib')
-rw-r--r-- | apps/provisioning_api/lib/Controller/UsersController.php | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php index e2952273520..60b8393e1e4 100644 --- a/apps/provisioning_api/lib/Controller/UsersController.php +++ b/apps/provisioning_api/lib/Controller/UsersController.php @@ -168,7 +168,7 @@ class UsersController extends OCSController { * @return DataResponse * @throws OCSException */ - public function addUser(string $userid, string $password, $groups = null): DataResponse { + public function addUser(string $userid, string $password, array $groups = []): DataResponse { $user = $this->userSession->getUser(); $isAdmin = $this->groupManager->isAdmin($user->getUID()); $subAdminManager = $this->groupManager->getSubAdmin(); @@ -178,7 +178,7 @@ class UsersController extends OCSController { throw new OCSException('User already exists', 102); } - if(is_array($groups)) { + if($groups !== []) { foreach ($groups as $group) { if(!$this->groupManager->groupExists($group)) { throw new OCSException('group '.$group.' does not exist', 104); @@ -197,12 +197,11 @@ class UsersController extends OCSController { $newUser = $this->userManager->createUser($userid, $password); $this->logger->info('Successful addUser call with userid: ' . $userid, ['app' => 'ocs_api']); - if (is_array($groups)) { - foreach ($groups as $group) { - $this->groupManager->get($group)->addUser($newUser); - $this->logger->info('Added userid ' . $userid . ' to group ' . $group, ['app' => 'ocs_api']); - } + foreach ($groups as $group) { + $this->groupManager->get($group)->addUser($newUser); + $this->logger->info('Added userid ' . $userid . ' to group ' . $group, ['app' => 'ocs_api']); } + return new DataResponse(); } catch (HintException $e ) { $this->logger->logException($e, [ |