summaryrefslogtreecommitdiffstats
path: root/apps/provisioning_api
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2018-09-12 09:40:27 +0200
committerJoas Schilling <coding@schilljs.com>2018-09-12 09:47:25 +0200
commitf0d48554d332444685b2a65f8a07e5a42fdd08ac (patch)
tree0ef27b5cdd3573b0ac79e82d2e68b2a5303fa2b0 /apps/provisioning_api
parent039145c4d1ed37f2163eba94858f695e355eb995 (diff)
downloadnextcloud-server-f0d48554d332444685b2a65f8a07e5a42fdd08ac.tar.gz
nextcloud-server-f0d48554d332444685b2a65f8a07e5a42fdd08ac.zip
Fix user and group listing with users that have an integer user id
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/provisioning_api')
-rw-r--r--apps/provisioning_api/lib/Controller/AUserData.php2
-rw-r--r--apps/provisioning_api/lib/Controller/GroupsController.php15
-rw-r--r--apps/provisioning_api/lib/Controller/UsersController.php17
3 files changed, 18 insertions, 16 deletions
diff --git a/apps/provisioning_api/lib/Controller/AUserData.php b/apps/provisioning_api/lib/Controller/AUserData.php
index f08fef91417..25e5ab5c86d 100644
--- a/apps/provisioning_api/lib/Controller/AUserData.php
+++ b/apps/provisioning_api/lib/Controller/AUserData.php
@@ -74,7 +74,7 @@ abstract class AUserData extends OCSController {
/**
* creates a array with all user data
*
- * @param $userId
+ * @param string $userId
* @return array
* @throws OCSException
*/
diff --git a/apps/provisioning_api/lib/Controller/GroupsController.php b/apps/provisioning_api/lib/Controller/GroupsController.php
index 2dbe2c8502f..e52929df9c6 100644
--- a/apps/provisioning_api/lib/Controller/GroupsController.php
+++ b/apps/provisioning_api/lib/Controller/GroupsController.php
@@ -186,26 +186,25 @@ class GroupsController extends AUserData {
* @throws OCSException
*/
public function getGroupUsersDetails(string $groupId, string $search = '', int $limit = null, int $offset = 0): DataResponse {
- $user = $this->userSession->getUser();
- $isSubadminOfGroup = false;
+ $currentUser = $this->userSession->getUser();
// Check the group exists
$group = $this->groupManager->get($groupId);
if ($group !== null) {
- $isSubadminOfGroup =$this->groupManager->getSubAdmin()->isSubAdminOfGroup($user, $group);
+ $isSubadminOfGroup = $this->groupManager->getSubAdmin()->isSubAdminOfGroup($currentUser, $group);
} else {
throw new OCSException('The requested group could not be found', \OCP\API::RESPOND_NOT_FOUND);
}
// Check subadmin has access to this group
- if($this->groupManager->isAdmin($user->getUID())
- || $isSubadminOfGroup) {
- $users = $this->groupManager->get($groupId)->searchUsers($search, $limit, $offset);
+ if($this->groupManager->isAdmin($currentUser->getUID()) || $isSubadminOfGroup) {
+ $users = $group->searchUsers($search, $limit, $offset);
// Extract required number
- $users = array_keys($users);
$usersDetails = [];
- foreach ($users as $userId) {
+ foreach ($users as $user) {
+ /** @var IUser $user */
+ $userId = (string) $user->getUID();
$userData = $this->getUserData($userId);
// Do not insert empty entry
if(!empty($userData)) {
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php
index d5e568b9184..9aa32e1186a 100644
--- a/apps/provisioning_api/lib/Controller/UsersController.php
+++ b/apps/provisioning_api/lib/Controller/UsersController.php
@@ -46,6 +46,7 @@ use OCP\IGroup;
use OCP\IGroupManager;
use OCP\ILogger;
use OCP\IRequest;
+use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\L10N\IFactory;
@@ -154,29 +155,31 @@ class UsersController extends AUserData {
* returns a list of users and their data
*/
public function getUsersDetails(string $search = '', $limit = null, $offset = 0): DataResponse {
- $user = $this->userSession->getUser();
+ $currentUser = $this->userSession->getUser();
$users = [];
// Admin? Or SubAdmin?
- $uid = $user->getUID();
+ $uid = $currentUser->getUID();
$subAdminManager = $this->groupManager->getSubAdmin();
if ($this->groupManager->isAdmin($uid)){
$users = $this->userManager->search($search, $limit, $offset);
- } else if ($subAdminManager->isSubAdmin($user)) {
- $subAdminOfGroups = $subAdminManager->getSubAdminsGroups($user);
+ $users = array_keys($users);
+ } else if ($subAdminManager->isSubAdmin($currentUser)) {
+ $subAdminOfGroups = $subAdminManager->getSubAdminsGroups($currentUser);
foreach ($subAdminOfGroups as $key => $group) {
$subAdminOfGroups[$key] = $group->getGID();
}
$users = [];
foreach ($subAdminOfGroups as $group) {
- $users = array_merge($users, $this->groupManager->displayNamesInGroup($group, $search, $limit, $offset));
+ $users[] = array_keys($this->groupManager->displayNamesInGroup($group, $search, $limit, $offset));
}
+ $users = array_merge(...$users);
}
- $users = array_keys($users);
$usersDetails = [];
- foreach ($users as $key => $userId) {
+ foreach ($users as $userId) {
+ $userId = (string) $userId;
$userData = $this->getUserData($userId);
// Do not insert empty entry
if (!empty($userData)) {