Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move /cloud/capabilities and /cloud/user to Core #777

Merged
merged 4 commits into from
Aug 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions core/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ public function __construct(array $urlParams=array()){
$container->registerService('TwoFactorAuthManager', function(SimpleContainer $c) {
return $c->query('ServerContainer')->getTwoFactorAuthManager();
});
$container->registerService('OC\CapabilitiesManager', function(SimpleContainer $c) {
return $c->query('ServerContainer')->getCapabilitiesManager();
});
}

}
88 changes: 88 additions & 0 deletions core/Controller/OCSController.php
Original file line number Diff line number Diff line change
@@ -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]);
}
}
4 changes: 4 additions & 0 deletions core/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
['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
Expand Down
55 changes: 0 additions & 55 deletions lib/private/OCS/Cloud.php

This file was deleted.

5 changes: 5 additions & 0 deletions lib/private/Route/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ public function loadRoutes($app = null) {
$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
Expand Down
28 changes: 0 additions & 28 deletions lib/private/legacy/ocs/cloud.php

This file was deleted.

15 changes: 0 additions & 15 deletions ocs/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,6 @@
'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')) {
Expand Down