Merge pull request #777 from nextcloud/ocs_capabilities
Move /cloud/capabilities and /cloud/user to Core
This commit is contained in:
commit
93047f5e4d
7 changed files with 100 additions and 98 deletions
|
@ -186,6 +186,9 @@ class Application extends App {
|
|||
$container->registerService('TwoFactorAuthManager', function(SimpleContainer $c) {
|
||||
return $c->query('ServerContainer')->getTwoFactorAuthManager();
|
||||
});
|
||||
$container->registerService('OC\CapabilitiesManager', function(SimpleContainer $c) {
|
||||
return $c->query('ServerContainer')->getCapabilitiesManager();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
88
core/Controller/OCSController.php
Normal file
88
core/Controller/OCSController.php
Normal file
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
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,
|
||||
IUserSession $userSession) {
|
||||
parent::__construct($appName, $request);
|
||||
|
||||
$this->capabilitiesManager = $capabilitiesManager;
|
||||
$this->userSession = $userSession;
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function getCapabilities() {
|
||||
$result = [];
|
||||
list($major, $minor, $micro) = \OCP\Util::getVersion();
|
||||
$result['version'] = array(
|
||||
'major' => $major,
|
||||
'minor' => $minor,
|
||||
'micro' => $micro,
|
||||
'string' => \OC_Util::getVersionString(),
|
||||
'edition' => \OC_Util::getEditionString(),
|
||||
);
|
||||
|
||||
$result['capabilities'] = $this->capabilitiesManager->getCapabilities();
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
|
@ -53,6 +53,10 @@ $application->registerRoutes($this, [
|
|||
['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'],
|
||||
['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'],
|
||||
],
|
||||
'ocs' => [
|
||||
['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'],
|
||||
['root' => '/cloud', 'name' => 'OCS#getCurrentUser', 'url' => '/user', 'verb' => 'GET'],
|
||||
],
|
||||
]);
|
||||
|
||||
// Post installation check
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
||||
*
|
||||
* @author Morris Jobke <hey@morrisjobke.de>
|
||||
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
||||
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
||||
* @author Tom Needham <tom@owncloud.com>
|
||||
*
|
||||
* @license AGPL-3.0
|
||||
*
|
||||
* This code is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License, version 3,
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OC\OCS;
|
||||
|
||||
class Cloud {
|
||||
|
||||
public static function getCapabilities() {
|
||||
$result = array();
|
||||
list($major, $minor, $micro) = \OCP\Util::getVersion();
|
||||
$result['version'] = array(
|
||||
'major' => $major,
|
||||
'minor' => $minor,
|
||||
'micro' => $micro,
|
||||
'string' => \OC_Util::getVersionString(),
|
||||
'edition' => \OC_Util::getEditionString(),
|
||||
);
|
||||
|
||||
$result['capabilities'] = \OC::$server->getCapabilitiesManager()->getCapabilities();
|
||||
|
||||
return new Result($result);
|
||||
}
|
||||
|
||||
public static function getCurrentUser() {
|
||||
$userObject = \OC::$server->getUserManager()->get(\OC_User::getUser());
|
||||
$data = array(
|
||||
'id' => $userObject->getUID(),
|
||||
'display-name' => $userObject->getDisplayName(),
|
||||
'email' => $userObject->getEMailAddress(),
|
||||
);
|
||||
return new Result($data);
|
||||
}
|
||||
}
|
|
@ -163,6 +163,11 @@ class Router implements IRouter {
|
|||
$this->useCollection('root');
|
||||
require_once __DIR__ . '/../../../settings/routes.php';
|
||||
require_once __DIR__ . '/../../../core/routes.php';
|
||||
|
||||
// Also add the OCS collection
|
||||
$collection = $this->getCollection('root.ocs');
|
||||
$collection->addPrefix('/ocsapp');
|
||||
$this->root->addCollection($collection);
|
||||
}
|
||||
if ($this->loaded) {
|
||||
// include ocs routes, must be loaded last for /ocs prefix
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
||||
*
|
||||
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
||||
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
||||
*
|
||||
* @license AGPL-3.0
|
||||
*
|
||||
* This code is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License, version 3,
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @deprecated Since 9.1.0 use \OC\OCS\Cloud
|
||||
*/
|
||||
class OC_OCS_Cloud extends \OC\OCS\Cloud {
|
||||
}
|
|
@ -83,21 +83,6 @@ API::register(
|
|||
'core',
|
||||
API::USER_AUTH
|
||||
);
|
||||
// cloud
|
||||
API::register(
|
||||
'get',
|
||||
'/cloud/capabilities',
|
||||
array('OC_OCS_Cloud', 'getCapabilities'),
|
||||
'core',
|
||||
API::USER_AUTH
|
||||
);
|
||||
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')) {
|
||||
|
|
Loading…
Reference in a new issue