diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2016-05-17 10:13:02 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2016-07-18 11:09:45 +0200 |
commit | 1caceea6c0fbd1dd9ccb24812f76c79e008c1dc1 (patch) | |
tree | 8668bbca6d9bb3dac036d062e1b71e5524c015e5 | |
parent | 94cd83ca00c5dd77b168bb21c494ff4fd8434ebc (diff) | |
download | nextcloud-server-1caceea6c0fbd1dd9ccb24812f76c79e008c1dc1.tar.gz nextcloud-server-1caceea6c0fbd1dd9ccb24812f76c79e008c1dc1.zip |
Make the OCS endpoint handle the new OCS AppFramework routes
-rw-r--r-- | lib/base.php | 2 | ||||
-rw-r--r-- | ocs/v1.php | 23 |
2 files changed, 24 insertions, 1 deletions
diff --git a/lib/base.php b/lib/base.php index 70fac6d707b..c915282cc7b 100644 --- a/lib/base.php +++ b/lib/base.php @@ -905,7 +905,7 @@ class OC { * @param OCP\IRequest $request * @return boolean */ - private static function handleLogin(OCP\IRequest $request) { + static function handleLogin(OCP\IRequest $request) { $userSession = self::$server->getUserSession(); if (OC_User::handleApacheAuth()) { return true; diff --git a/ocs/v1.php b/ocs/v1.php index bbc2adf39b6..fe7c9a2441d 100644 --- a/ocs/v1.php +++ b/ocs/v1.php @@ -42,6 +42,10 @@ if (\OCP\Util::needUpgrade() use Symfony\Component\Routing\Exception\ResourceNotFoundException; use Symfony\Component\Routing\Exception\MethodNotAllowedException; +/* + * Try old routes first + * We first try the old routes since the appframework triggers more login stuff. + */ try { OC_App::loadApps(['session']); OC_App::loadApps(['authentication']); @@ -52,6 +56,22 @@ try { \OC::$server->getL10NFactory()->setLanguageFromRequest(); OC::$server->getRouter()->match('/ocs'.\OC::$server->getRequest()->getRawPathInfo()); + return; +} catch (ResourceNotFoundException $e) { + // Fall through the not found +} catch (MethodNotAllowedException $e) { + OC_API::setContentType(); + OC_Response::setStatus(405); +} catch (\OC\OCS\Exception $ex) { + OC_API::respond($ex->getResult(), OC_API::requestedFormat()); +} + +/* + * Try the appframework routes + */ +try { + OC::handleLogin(\OC::$server->getRequest()); + OC::$server->getRouter()->match('/ocsapp'.\OC::$server->getRequest()->getRawPathInfo()); } catch (ResourceNotFoundException $e) { OC_API::setContentType(); OC_OCS::notFound(); @@ -60,5 +80,8 @@ try { OC_Response::setStatus(405); } catch (\OC\OCS\Exception $ex) { OC_API::respond($ex->getResult(), OC_API::requestedFormat()); +} catch (\Exception $e) { + OC_API::setContentType(); + OC_OCS::notFound(); } |