diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 5d8763c7bfe..2730c6c0242 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -37,9 +37,9 @@ if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not lo if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) -$DOLAPIENTITY = $_SERVER['HTTP_DOLAPIENTITY']; -$entity=(! empty($DOLAPIENTITY) ? (int) $DOLAPIENTITY : (! empty($DOLAPIENTITY) ? (int) $DOLAPIENTITY : 1)); -if (is_numeric($entity)) define("DOLENTITY", $entity); +// Force entity if a value provided int HTTP header. Otherwise, will use the entity of user of token used. +if (! empty($_SERVER['HTTP_DOLAPIENTITY'])) define("DOLENTITY", (int) $_SERVER['HTTP_DOLAPIENTITY']); + $res=0; if (! $res && file_exists("../main.inc.php")) $res=include '../main.inc.php';