Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2016-02-22 11:41:56 +0300
committerLukas Reschke <lukas@owncloud.com>2016-02-22 11:41:56 +0300
commit6c96b3d07f7248d1ab4066dbf71025753de1a0a9 (patch)
tree71fa05b693ea0064c7fd2b191059c31ae44ab800 /settings
parent8a8209796d4577644228121edc2231ae027217c7 (diff)
Throw normal exceptions instead of eating them
Partially addresses https://github.com/owncloud/core/issues/22550 Replaces https://github.com/owncloud/core/pull/20185
Diffstat (limited to 'settings')
-rw-r--r--settings/middleware/subadminmiddleware.php14
1 files changed, 10 insertions, 4 deletions
diff --git a/settings/middleware/subadminmiddleware.php b/settings/middleware/subadminmiddleware.php
index 00f221721a6..8e138bdc1a8 100644
--- a/settings/middleware/subadminmiddleware.php
+++ b/settings/middleware/subadminmiddleware.php
@@ -23,6 +23,7 @@
namespace OC\Settings\Middleware;
use OC\AppFramework\Http;
+use OC\Appframework\Middleware\Security\Exceptions\NotAdminException;
use OC\AppFramework\Utility\ControllerMethodReflector;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Middleware;
@@ -58,7 +59,7 @@ class SubadminMiddleware extends Middleware {
public function beforeController($controller, $methodName) {
if(!$this->reflector->hasAnnotation('NoSubadminRequired')) {
if(!$this->isSubAdmin) {
- throw new \Exception('Logged in user must be a subadmin');
+ throw new NotAdminException('Logged in user must be a subadmin');
}
}
}
@@ -69,11 +70,16 @@ class SubadminMiddleware extends Middleware {
* @param string $methodName
* @param \Exception $exception
* @return TemplateResponse
+ * @throws \Exception
*/
public function afterException($controller, $methodName, \Exception $exception) {
- $response = new TemplateResponse('core', '403', array(), 'guest');
- $response->setStatus(Http::STATUS_FORBIDDEN);
- return $response;
+ if($exception instanceof NotAdminException) {
+ $response = new TemplateResponse('core', '403', array(), 'guest');
+ $response->setStatus(Http::STATUS_FORBIDDEN);
+ return $response;
+ }
+
+ throw $exception;
}
}