From 6d8812abb53ca43ff75f737477ef7eb4dfc670cd Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Wed, 28 Jul 2021 17:16:43 +0200 Subject: [PATCH] display_ajax_return(): Return HTTP 400 error code if success==false in retourned data --- includes/smarty.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/smarty.php b/includes/smarty.php index 5b8fdb4..17ce792 100644 --- a/includes/smarty.php +++ b/includes/smarty.php @@ -150,6 +150,10 @@ function display_ajax_return($data=null, $pretty=false) { global $debug_ajax; if (is_null($data)) $data = array(); + // Adjust HTTP error code on unsuccessfull request + elseif (isset($data['success']) && !$data['success'] && http_response_code() == 200) + http_response_code(400); + if (isset($_SESSION['messages']) && !empty($_SESSION['messages'])) { $data['messages'] = $_SESSION['messages']; unset($_SESSION['messages']);