reflector = $reflector; $this->isSubAdmin = $isSubAdmin; } /** * Check if sharing is enabled before the controllers is executed * @param \OCP\AppFramework\Controller $controller * @param string $methodName * @throws \Exception */ public function beforeController($controller, $methodName) { if(!$this->reflector->hasAnnotation('NoSubadminRequired')) { if(!$this->isSubAdmin) { throw new \Exception('Logged in user must be a subadmin'); } } } /** * Return 403 page in case of an exception * @param \OCP\AppFramework\Controller $controller * @param string $methodName * @param \Exception $exception * @return TemplateResponse */ public function afterException($controller, $methodName, \Exception $exception) { $response = new TemplateResponse('core', '403', array(), 'guest'); $response->setStatus(Http::STATUS_FORBIDDEN); return $response; } }