From 9b9162b27a44d26a1ac8ef6bf8d9919b07ef4bc0 Mon Sep 17 00:00:00 2001 From: Loz Calver Date: Mon, 6 Mar 2023 09:18:14 +0000 Subject: [PATCH] Suppress admin error context for base 'CMS access' permission check (fixes #1443) --- code/LeftAndMain.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/code/LeftAndMain.php b/code/LeftAndMain.php index 159830647..06e996db1 100644 --- a/code/LeftAndMain.php +++ b/code/LeftAndMain.php @@ -181,6 +181,11 @@ class LeftAndMain extends Controller implements PermissionProvider */ private string $httpErrorMessage; + /** + * Used to allow errors to be displayed using a front-end template + */ + private bool $suppressAdminErrorContext = false; + /** * Assign themes to use for cms * @@ -660,6 +665,7 @@ protected function init() ), ]; + $this->suppressAdminErrorContext = true; Security::permissionFailure($this, $messageSet); return; } @@ -781,7 +787,8 @@ protected function init() public function afterHandleRequest() { - if ($this->response->isError() + if (!$this->suppressAdminErrorContext + && $this->response->isError() && !$this->request->isAjax() && $this->response->getHeader('Content-Type') !== 'application/json' ) {