From 5086335643b6181284ee50f57b95525002842992 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Tue, 24 Jan 2017 15:45:55 +0100 Subject: unify endpoints form core and the the provisioning api Signed-off-by: Bjoern Schiessle --- .../lib/Controller/UsersController.php | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'apps/provisioning_api/lib') diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php index e659b49443b..45839cf4f8d 100644 --- a/apps/provisioning_api/lib/Controller/UsersController.php +++ b/apps/provisioning_api/lib/Controller/UsersController.php @@ -218,6 +218,7 @@ class UsersController extends OCSController { $userAccount = $this->accountManager->getUser($targetUserObject); // Find the data + $data['id'] = $targetUserObject->getUID(); $data['quota'] = $this->fillStorageInfo($userId); $data['email'] = $targetUserObject->getEMailAddress(); $data['displayname'] = $targetUserObject->getDisplayName(); @@ -229,6 +230,30 @@ class UsersController extends OCSController { 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); + } + /** * @NoAdminRequired * @NoSubAdminRequired -- cgit v1.2.3