39 global $db,
$conf, $langs;
40 global $dolibarr_main_authentication, $dolibarr_auto_user;
42 $fuser =
new User($db);
44 if (!$error && ($authentication[
'dolibarrkey'] !=
$conf->global->WEBSERVICES_KEY)) {
46 $errorcode =
'BAD_VALUE_FOR_SECURITY_KEY';
47 $errorlabel =
'Value provided into dolibarrkey entry field does not match security key defined in Webservice module setup';
50 if (!$error && !empty($authentication[
'entity']) && !is_numeric($authentication[
'entity'])) {
52 $errorcode =
'BAD_PARAMETERS';
53 $errorlabel =
"The entity parameter must be empty (or filled with numeric id of instance if multicompany module is used).";
57 $result = $fuser->fetch(0, $authentication[
'login'],
'', 0);
60 $errorcode =
'ERROR_FETCH_USER';
61 $errorlabel =
'A technical error occurred during fetch of user';
62 } elseif ($result == 0) {
64 $errorcode =
'BAD_CREDENTIALS';
65 $errorlabel =
'Bad value for login or password';
68 if (!$error && $fuser->statut == 0) {
70 $errorcode =
'ERROR_USER_DISABLED';
71 $errorlabel =
'This user has been locked or disabled';
79 if (empty($dolibarr_main_authentication) || $dolibarr_main_authentication ==
'openid_connect') {
80 $dolibarr_main_authentication =
'http,dolibarr';
83 if ($dolibarr_main_authentication ==
'forceuser' && empty($dolibarr_auto_user)) {
84 $dolibarr_auto_user =
'auto';
87 $authmode = explode(
',', $dolibarr_main_authentication);
89 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
90 $login =
checkLoginPassEntity($authentication[
'login'], $authentication[
'password'], (
string) $authentication[
'entity'], $authmode,
'ws');
91 if ($login ===
'--bad-login-validity--') {
97 $errorcode =
'BAD_CREDENTIALS';
98 $errorlabel =
'Bad value for login or password';
checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $authmode, $context='')
Return a login if login/pass was successful.
check_authentication($authentication, &$error, &$errorcode, &$errorlabel)
Check authentication array and set error, errorcode, errorlabel.