summaryrefslogtreecommitdiffstats
path: root/apps/provisioning_api/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2015-10-30 09:30:00 +0100
committerRoeland Jago Douma <rullzer@owncloud.com>2015-11-12 22:31:17 +0100
commitfc1f0233ffd777220c3128a0e727041c4c62ac72 (patch)
tree454d0afc65ddca2d2fc6591547d8ea6c3f062123 /apps/provisioning_api/lib
parent3b88c469c781e5255663e81c7c6b0459cbba34b2 (diff)
downloadnextcloud-server-fc1f0233ffd777220c3128a0e727041c4c62ac72.tar.gz
nextcloud-server-fc1f0233ffd777220c3128a0e727041c4c62ac72.zip
Added unit test for new functionality
Diffstat (limited to 'apps/provisioning_api/lib')
-rw-r--r--apps/provisioning_api/lib/users.php15
1 files changed, 8 insertions, 7 deletions
diff --git a/apps/provisioning_api/lib/users.php b/apps/provisioning_api/lib/users.php
index 49199d4169c..a2568425d0f 100644
--- a/apps/provisioning_api/lib/users.php
+++ b/apps/provisioning_api/lib/users.php
@@ -120,8 +120,9 @@ class Users {
$groups = isset($_POST['groups']) ? $_POST['groups'] : null;
$user = $this->userSession->getUser();
$isAdmin = $this->groupManager->isAdmin($user->getUID());
+ $subAdminManager = $this->groupManager->getSubAdmin();
- if (!$isAdmin && !$this->groupManager->getSubAdmin()->isSubAdmin($user)) {
+ if (!$isAdmin && !$subAdminManager->isSubAdmin($user)) {
return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED);
}
@@ -131,11 +132,11 @@ class Users {
}
if(is_array($groups)) {
- foreach ($groups as $key => $group) {
+ foreach ($groups as $group) {
if(!$this->groupManager->groupExists($group)){
return new OC_OCS_Result(null, 104, 'group '.$group.' does not exist');
}
- if(!$isAdmin && !$this->groupManager->getSubAdmin()->isSubAdminofGroup($user, $this->groupManager->get($group))) {
+ if(!$isAdmin && !$subAdminManager->isSubAdminofGroup($user, $this->groupManager->get($group))) {
return new OC_OCS_Result(null, 105, 'insufficient privileges for group '. $group);
}
}
@@ -146,13 +147,13 @@ class Users {
}
try {
- $user = $this->userManager->createUser($userId, $password);
- $this->logger->info('Successful addUser call with userid: '.$_POST['userid'], ['app' => 'ocs_api']);
+ $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($user);
- $this->logger->info('Added user (' . $user->getUID() . ') to group ' . $group, ['app' => 'ocs_api']);
+ $this->groupManager->get($group)->addUser($newUser);
+ $this->logger->info('Added userid '.$userId.' to group '.$group, ['app' => 'ocs_api']);
}
}
return new OC_OCS_Result(null, 100);