Make the OCS endpoint handle the new OCS AppFramework routes

This commit is contained in:
Roeland Jago Douma 2016-05-17 10:13:02 +02:00 committed by Roeland Jago Douma
parent 94cd83ca00
commit 1caceea6c0
No known key found for this signature in database
GPG Key ID: 1E152838F164D13B
2 changed files with 24 additions and 1 deletions

View File

@ -905,7 +905,7 @@ class OC {
* @param OCP\IRequest $request * @param OCP\IRequest $request
* @return boolean * @return boolean
*/ */
private static function handleLogin(OCP\IRequest $request) { static function handleLogin(OCP\IRequest $request) {
$userSession = self::$server->getUserSession(); $userSession = self::$server->getUserSession();
if (OC_User::handleApacheAuth()) { if (OC_User::handleApacheAuth()) {
return true; return true;

View File

@ -42,6 +42,10 @@ if (\OCP\Util::needUpgrade()
use Symfony\Component\Routing\Exception\ResourceNotFoundException; use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\Routing\Exception\MethodNotAllowedException; use Symfony\Component\Routing\Exception\MethodNotAllowedException;
/*
* Try old routes first
* We first try the old routes since the appframework triggers more login stuff.
*/
try { try {
OC_App::loadApps(['session']); OC_App::loadApps(['session']);
OC_App::loadApps(['authentication']); OC_App::loadApps(['authentication']);
@ -52,6 +56,22 @@ try {
\OC::$server->getL10NFactory()->setLanguageFromRequest(); \OC::$server->getL10NFactory()->setLanguageFromRequest();
OC::$server->getRouter()->match('/ocs'.\OC::$server->getRequest()->getRawPathInfo()); 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) { } catch (ResourceNotFoundException $e) {
OC_API::setContentType(); OC_API::setContentType();
OC_OCS::notFound(); OC_OCS::notFound();
@ -60,5 +80,8 @@ try {
OC_Response::setStatus(405); OC_Response::setStatus(405);
} catch (\OC\OCS\Exception $ex) { } catch (\OC\OCS\Exception $ex) {
OC_API::respond($ex->getResult(), OC_API::requestedFormat()); OC_API::respond($ex->getResult(), OC_API::requestedFormat());
} catch (\Exception $e) {
OC_API::setContentType();
OC_OCS::notFound();
} }