FIX: Add security test for show terminal selection if no terminal selected when invoice.php is call (#34717)

* FIX: Add security test for show terminal selection if no terminal selected when invoice.php is call

* Modification to take into account the value saved in the cookie

* Update invoice.php

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
kkhelifa-opendsi 2025-09-03 16:36:18 +02:00 committed by GitHub
parent 2d55195982
commit 247c38923f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -78,6 +78,23 @@ if ((getDolGlobalString('TAKEPOS_PHONE_BASIC_LAYOUT') == 1 && $conf->browser->la
}
}
// When session has expired (selected terminal has been lost from session), redirect to the terminal selection.
if (empty($_SESSION["takeposterminal"])) {
if (getDolGlobalInt('TAKEPOS_NUM_TERMINALS') == 1) {
$_SESSION["takeposterminal"] = 1; // Use terminal 1 if there is only 1 terminal
} elseif (!empty($_COOKIE["takeposterminal"])) {
$_SESSION["takeposterminal"] = preg_replace('/[^a-zA-Z0-9_\-]/', '', $_COOKIE["takeposterminal"]); // Restore takeposterminal from previous session
} else {
print <<<SCRIPT
<script language="javascript">
$( document ).ready(function() {
ModalBox('ModalTerminal');
});
</script>
SCRIPT;
exit;
}
}
/**
* Abort invoice creationg with a given error message