]> source.dussan.org Git - nextcloud-server.git/commitdiff
Move /cloud/user to Core app
authorRoeland Jago Douma <roeland@famdouma.nl>
Tue, 9 Aug 2016 09:27:55 +0000 (11:27 +0200)
committerRoeland Jago Douma <roeland@famdouma.nl>
Tue, 9 Aug 2016 18:56:31 +0000 (20:56 +0200)
core/Controller/OCSController.php
core/routes.php
ocs/routes.php

index 750ab37eb88d64103f3bcf29c643041ac04a66be..d5783ae32e999a4922fa51db11b73b24ad158f36 100644 (file)
@@ -24,25 +24,32 @@ namespace OC\Core\Controller;
 use OC\CapabilitiesManager;
 use OCP\AppFramework\Http\DataResponse;
 use OCP\IRequest;
+use OCP\IUserSession;
 
 class OCSController extends \OCP\AppFramework\OCSController {
 
        /** @var CapabilitiesManager */
        private $capabilitiesManager;
 
+       /** @var IUserSession */
+       private $userSession;
+
        /**
         * OCSController constructor.
         *
         * @param string $appName
         * @param IRequest $request
         * @param CapabilitiesManager $capabilitiesManager
+        * @param IUserSession $userSession
         */
        public function __construct($appName,
                                                                IRequest $request,
-                                                               CapabilitiesManager $capabilitiesManager) {
+                                                               CapabilitiesManager $capabilitiesManager,
+                                                               IUserSession $userSession) {
                parent::__construct($appName, $request);
 
                $this->capabilitiesManager = $capabilitiesManager;
+               $this->userSession = $userSession;
        }
 
        /**
@@ -64,4 +71,18 @@ class OCSController extends \OCP\AppFramework\OCSController {
 
                return new DataResponse(['data' => $result]);
        }
+
+       /**
+        * @NoAdminRequired
+        * @return DataResponse
+        */
+       public function getCurrentUser() {
+               $userObject = $this->userSession->getUser();
+               $data  = [
+                       'id' => $userObject->getUID(),
+                       'display-name' => $userObject->getDisplayName(),
+                       'email' => $userObject->getEMailAddress(),
+               ];
+               return new DataResponse(['data' => $data]);
+       }
 }
index 92ce4440ecfde9567f9911e9b3cd1668f39b59fd..b4868c14cf3143f971f65628a0e466fd10e26685 100644 (file)
@@ -55,6 +55,7 @@ $application->registerRoutes($this, [
        ],
        'ocs' => [
                ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'],
+               ['root' => '/cloud', 'name' => 'OCS#getCurrentUser', 'url' => '/user', 'verb' => 'GET'],
        ],
 ]);
 
index bb24c79eba7cf317c8452930fedb65540a0ad288..ae2ef05adcd46c43da2dc8463a2551432b771cd4 100644 (file)
@@ -83,14 +83,6 @@ API::register(
        'core',
        API::USER_AUTH
        );
-// cloud
-API::register(
-       'get',
-       '/cloud/user',
-       array('OC_OCS_Cloud', 'getCurrentUser'),
-       'core',
-       API::USER_AUTH
-);
 
 // Server-to-Server Sharing
 if (\OC::$server->getAppManager()->isEnabledForUser('files_sharing')) {