diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-03-16 09:38:09 +0100 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-03-16 09:38:09 +0100 |
commit | aa1e8713fbdd8332537a6a9b51c1954ef81790b7 (patch) | |
tree | c475489d071e181c8c8e9dcde07da61a7291c27c /apps/provisioning_api | |
parent | ce625bbad52bd7d416d5fdaac6bef399feaf0c3b (diff) | |
download | nextcloud-server-aa1e8713fbdd8332537a6a9b51c1954ef81790b7.tar.gz nextcloud-server-aa1e8713fbdd8332537a6a9b51c1954ef81790b7.zip |
Fixed throw error on unreachable users
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/provisioning_api')
-rw-r--r-- | apps/provisioning_api/lib/Controller/UsersController.php | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php index 17c04c708f1..2c6955b0dbb 100644 --- a/apps/provisioning_api/lib/Controller/UsersController.php +++ b/apps/provisioning_api/lib/Controller/UsersController.php @@ -199,7 +199,7 @@ class UsersController extends OCSController { $users = array_keys($users); $usersDetails = []; foreach ($users as $key => $userId) { - $usersDetails[$userId] = $this->getUserData($userId); + $usersDetails[$userId] = $this->getUserData($userId, false); } return new DataResponse([ @@ -315,7 +315,7 @@ class UsersController extends OCSController { * @return array * @throws OCSException */ - protected function getUserData(string $userId): array { + protected function getUserData(string $userId, bool $throw = true): array { $currentLoggedInUser = $this->userSession->getUser(); $data = []; @@ -329,15 +329,15 @@ class UsersController extends OCSController { // Admin? Or SubAdmin? if($this->groupManager->isAdmin($currentLoggedInUser->getUID()) || $this->groupManager->getSubAdmin()->isUserAccessible($currentLoggedInUser, $targetUserObject)) { + $data['enabled'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'enabled', 'true'); - $data['storageLocation'] = $targetUserObject->getHome(); - $data['lastLogin'] = $targetUserObject->getLastLogin() * 1000; - $data['backend'] = $targetUserObject->getBackendClassName(); - $data['subadmins'] = $this->getUserSubAdminGroupsData($targetUserObject->getUID()); + } else { // Check they are looking up themselves - if($currentLoggedInUser->getUID() !== $targetUserObject->getUID()) { + if($currentLoggedInUser->getUID() !== $targetUserObject->getUID() && $throw) { throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED); + } else { + return $data; } } @@ -351,6 +351,10 @@ class UsersController extends OCSController { // Find the data $data['id'] = $targetUserObject->getUID(); + $data['storageLocation'] = $targetUserObject->getHome(); + $data['lastLogin'] = $targetUserObject->getLastLogin() * 1000; + $data['backend'] = $targetUserObject->getBackendClassName(); + $data['subadmins'] = $this->getUserSubAdminGroupsData($targetUserObject->getUID()); $data['quota'] = $this->fillStorageInfo($targetUserObject->getUID()); $data[AccountManager::PROPERTY_EMAIL] = $targetUserObject->getEMailAddress(); $data[AccountManager::PROPERTY_DISPLAYNAME] = $targetUserObject->getDisplayName(); |