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' ) {