Skip to content

Commit

Permalink
Suppress admin error context for base 'CMS access' permission check (f…
Browse files Browse the repository at this point in the history
  • Loading branch information
kinglozzer committed Mar 6, 2023
1 parent 99082e8 commit 9b9162b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion code/LeftAndMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -660,6 +665,7 @@ protected function init()
),
];

$this->suppressAdminErrorContext = true;
Security::permissionFailure($this, $messageSet);
return;
}
Expand Down Expand Up @@ -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'
) {
Expand Down

0 comments on commit 9b9162b

Please sign in to comment.