Skip to content

Commit

Permalink
CommandActions: Only respond with JSON if it's an API request
Browse files Browse the repository at this point in the history
fixes #945
  • Loading branch information
nilmerg committed Mar 18, 2024
1 parent 4293461 commit c2e977b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions library/Icingadb/Common/CommandActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ protected function assertIsGrantedOnCommandTargets(string $permission)
protected function handleCommandForm($form)
{
$isXhr = $this->getRequest()->isXmlHttpRequest();
if ($isXhr && $this->getRequest()->isApiRequest()) {
$isApi = $this->getRequest()->isApiRequest();
if ($isXhr && $isApi) {
// Prevents the framework already, this is just a fail-safe
$this->httpBadRequest('Responding with JSON during a Web request is not supported');
}
Expand All @@ -151,7 +152,7 @@ protected function handleCommandForm($form)

$form->setObjects($this->getCommandTargets());

if ($isXhr) {
if (! $isApi || $isXhr) {
$this->handleWebRequest($form);
} else {
$this->handleApiRequest($form);
Expand Down

0 comments on commit c2e977b

Please sign in to comment.