summaryrefslogtreecommitdiffstats
path: root/apps/provisioning_api/lib
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2017-01-26 11:31:08 +0100
committerBjoern Schiessle <bjoern@schiessle.org>2017-01-26 11:31:08 +0100
commit3e6c40eeb4408f3f52bdabad5ae876dc0e5581ff (patch)
treec0b346a08ba9ac945fdd587b0101c06ad86dc528 /apps/provisioning_api/lib
parent3a603ab8b421b306373e06b9d1210e6013093a99 (diff)
downloadnextcloud-server-3e6c40eeb4408f3f52bdabad5ae876dc0e5581ff.tar.gz
nextcloud-server-3e6c40eeb4408f3f52bdabad5ae876dc0e5581ff.zip
make sure that 'getCurrentUser' gets an array in order to manipulate the data to match the old API
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps/provisioning_api/lib')
-rw-r--r--apps/provisioning_api/lib/Controller/UsersController.php62
1 files changed, 37 insertions, 25 deletions
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php
index 45839cf4f8d..1e8a767b33a 100644
--- a/apps/provisioning_api/lib/Controller/UsersController.php
+++ b/apps/provisioning_api/lib/Controller/UsersController.php
@@ -194,6 +194,42 @@ class UsersController extends OCSController {
* @throws OCSException
*/
public function getUser($userId) {
+ $data = $this->getUserData($userId);
+ return new DataResponse($data);
+ }
+
+ /**
+ * @NoAdminRequired
+ * @NoSubAdminRequired
+ *
+ * gets user info from the currently logged in user
+ *
+ * @return DataResponse
+ * @throws OCSException
+ */
+ public function getCurrentUser() {
+ $user = $this->userSession->getUser();
+ if ($user) {
+ $data = $this->getUserData($user->getUID());
+ // rename "displayname" to "display-name" only for this call to keep
+ // the API stable.
+ $data['display-name'] = $data['displayname'];
+ unset($data['displayname']);
+ return new DataResponse($data);
+
+ }
+
+ throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
+ }
+
+ /**
+ * creates a array with all user data
+ *
+ * @param $userId
+ * @return array
+ * @throws OCSException
+ */
+ protected function getUserData($userId) {
$currentLoggedInUser = $this->userSession->getUser();
$data = [];
@@ -227,31 +263,7 @@ class UsersController extends OCSController {
$data['webpage'] = $userAccount[\OC\Accounts\AccountManager::PROPERTY_WEBSITE]['value'];
$data['twitter'] = $userAccount[\OC\Accounts\AccountManager::PROPERTY_TWITTER]['value'];
- return new DataResponse($data);
- }
-
- /**
- * @NoAdminRequired
- * @NoSubAdminRequired
- *
- * gets user info from the currently logged in user
- *
- * @return DataResponse
- * @throws OCSException
- */
- public function getCurrentUser() {
- $user = $this->userSession->getUser();
- if ($user) {
- $result = $this->getUser($user->getUID());
- // rename "displayname" to "display-name" only for this call to keep
- // the API stable.
- $result['display-name'] = $result['displayname'];
- unset($result['displayname']);
- return $result;
-
- }
-
- throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED);
+ return $data;
}
/**