37 global $db, $conf, $langs;
38 global $dolibarr_main_authentication, $dolibarr_auto_user;
40 $fuser =
new User($db);
42 if (!$error && ($authentication[
'dolibarrkey'] != $conf->global->WEBSERVICES_KEY)) {
44 $errorcode =
'BAD_VALUE_FOR_SECURITY_KEY';
45 $errorlabel =
'Value provided into dolibarrkey entry field does not match security key defined in Webservice module setup';
48 if (!$error && !empty($authentication[
'entity']) && !is_numeric($authentication[
'entity'])) {
50 $errorcode =
'BAD_PARAMETERS';
51 $errorlabel =
"The entity parameter must be empty (or filled with numeric id of instance if multicompany module is used).";
55 $result = $fuser->fetch(
'', $authentication[
'login'],
'', 0);
58 $errorcode =
'ERROR_FETCH_USER';
59 $errorlabel =
'A technical error occurred during fetch of user';
60 } elseif ($result == 0) {
62 $errorcode =
'BAD_CREDENTIALS';
63 $errorlabel =
'Bad value for login or password';
66 if (!$error && $fuser->statut == 0) {
68 $errorcode =
'ERROR_USER_DISABLED';
69 $errorlabel =
'This user has been locked or disabled';
77 if (empty($dolibarr_main_authentication)) {
78 $dolibarr_main_authentication =
'http,dolibarr';
81 if ($dolibarr_main_authentication ==
'forceuser' && empty($dolibarr_auto_user)) {
82 $dolibarr_auto_user =
'auto';
85 $authmode = explode(
',', $dolibarr_main_authentication);
87 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
88 $login =
checkLoginPassEntity($authentication[
'login'], $authentication[
'password'], $authentication[
'entity'], $authmode,
'ws');
89 if ($login ===
'--bad-login-validity--') {
95 $errorcode =
'BAD_CREDENTIALS';
96 $errorlabel =
'Bad value for login or password';
checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $authmode, $context='')
Return a login if login/pass was successfull.
check_authentication($authentication, &$error, &$errorcode, &$errorlabel)
Check authentication array and set error, errorcode, errorlabel.