Skip to content

Commit 3f55de9

Browse files
committed
fix(AuthorizedAdminSettingMiddleware): Correctly type exception handling
Signed-off-by: provokateurin <[email protected]>
1 parent e334d8c commit 3f55de9

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

β€Žlib/AuthorizedAdminSettingMiddleware.php

+7-6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use OCA\GroupFolders\Attribute\RequireGroupFolderAdmin;
1212
use OCA\GroupFolders\Service\DelegationService;
1313
use OCP\AppFramework\Controller;
14+
use OCP\AppFramework\Http;
1415
use OCP\AppFramework\Http\JSONResponse;
1516
use OCP\AppFramework\Http\Response;
1617
use OCP\AppFramework\Http\TemplateResponse;
@@ -36,16 +37,16 @@ public function beforeController(Controller $controller, string $methodName): vo
3637
}
3738

3839
public function afterException(Controller $controller, string $methodName, Exception $exception): Response {
40+
/** @var Http::STATUS_* $code */
41+
$code = $exception->getCode();
42+
3943
if (stripos($this->request->getHeader('Accept'), 'html') === false) {
40-
$response = new JSONResponse(
44+
return new JSONResponse(
4145
['message' => $exception->getMessage()],
42-
(int)$exception->getCode()
46+
$code
4347
);
44-
} else {
45-
$response = new TemplateResponse('core', '403', ['message' => $exception->getMessage()], 'guest');
46-
$response->setStatus((int)$exception->getCode());
4748
}
4849

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

0 commit comments

Comments
Β (0)