Skip to content

Commit

Permalink
Merge pull request #3534 from nextcloud/automated/noid/master-update-…
Browse files Browse the repository at this point in the history
…nextcloud-ocp

[master] Update nextcloud/ocp dependency
  • Loading branch information
github-actions[bot] authored Jan 20, 2025
2 parents fcb69e7 + 3f55de9 commit 94ef2a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
8 changes: 4 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions lib/AuthorizedAdminSettingMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use OCA\GroupFolders\Attribute\RequireGroupFolderAdmin;
use OCA\GroupFolders\Service\DelegationService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Http\TemplateResponse;
Expand All @@ -36,16 +37,16 @@ public function beforeController(Controller $controller, string $methodName): vo
}

public function afterException(Controller $controller, string $methodName, Exception $exception): Response {
/** @var Http::STATUS_* $code */
$code = $exception->getCode();

if (stripos($this->request->getHeader('Accept'), 'html') === false) {
$response = new JSONResponse(
return new JSONResponse(
['message' => $exception->getMessage()],
(int)$exception->getCode()
$code
);
} else {
$response = new TemplateResponse('core', '403', ['message' => $exception->getMessage()], 'guest');
$response->setStatus((int)$exception->getCode());
}

return $response;
return new TemplateResponse('core', '403', ['message' => $exception->getMessage()], 'guest', $code);
}
}

0 comments on commit 94ef2a1

Please sign in to comment.