Merge pull request #18543 from lainwir3d/fix_restapi_global_user_variable

FIX #18542 REST API: set global $user variable to DolibarrApiAccess::user
This commit is contained in:
Laurent Destailleur 2021-09-01 18:05:40 +02:00 committed by GitHub
commit 7e8ce82e0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -80,7 +80,7 @@ class DolibarrApiAccess implements iAuthenticate
public function __isAllowed() public function __isAllowed()
{ {
// phpcs:enable // phpcs:enable
global $conf, $db; global $conf, $db, $user;
$login = ''; $login = '';
$stored_key = ''; $stored_key = '';
@ -150,6 +150,9 @@ class DolibarrApiAccess implements iAuthenticate
$fuser->getrights(); $fuser->getrights();
static::$user = $fuser; static::$user = $fuser;
// Set the global variable $user to the $user of API
$user = $fuser;
if ($fuser->socid) { if ($fuser->socid) {
static::$role = 'external'; static::$role = 'external';
} }