Skip to content

Commit

Permalink
fix(formanswer): redirect after submit may lead to unavailable page
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Oct 10, 2023
1 parent 7b9e941 commit 599451a
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions ajax/formanswer.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,28 +88,29 @@
}

// redirect to created item
if ($_SESSION['glpibackcreated'] && Ticket::canView()) {
if (strpos($_SERVER['HTTP_REFERER'], 'form.form.php') === false) {
// User was not testing the form from preview
if (count($formAnswer->targetList) == 1) {
$target = current($formAnswer->targetList);
echo json_encode(
[
'redirect' => $target->getFormURLWithID($target->getID()),
], JSON_FORCE_OBJECT
);
die();
}
if ($_SESSION['glpibackcreated']) {
if (strpos($_SERVER['HTTP_REFERER'], 'form.form.php') !== false) {
echo json_encode(
[
'redirect' => $formAnswer->getFormURLWithID($formAnswer->getID()),
'redirect' => (new PluginFormcreatorForm())->getFormURLWithID($formAnswer->fields['plugin_formcreator_forms_id']),
], JSON_FORCE_OBJECT
);
die();
}
// User was not testing the form from preview
reset($formAnswer->targetList);
$target = current($formAnswer->targetList);
if (count($formAnswer->targetList) == 1 && $target::canView()) {
echo json_encode(
[
'redirect' => $target->getFormURLWithID($target->getID()),
], JSON_FORCE_OBJECT
);
die();
}
echo json_encode(
[
'redirect' => (new PluginFormcreatorForm())->getFormURLWithID($formAnswer->fields['plugin_formcreator_forms_id']),
'redirect' => $formAnswer->getFormURLWithID($formAnswer->getID()),
], JSON_FORCE_OBJECT
);
die();
Expand Down

0 comments on commit 599451a

Please sign in to comment.