Skip to content

Commit

Permalink
Merge pull request silverstripe#1466 from kinglozzer/1443-error-context
Browse files Browse the repository at this point in the history
Suppress admin error context for base 'CMS access' permission check (fixes silverstripe#1443)
  • Loading branch information
GuySartorelli authored Mar 7, 2023
2 parents 99082e8 + 9b9162b commit 42c0ce4
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 42c0ce4

Please sign in to comment.