function verif($aLogin, $aPasswd)
 {
     global $conf, $dolibarr_main_authentication, $langs;
     $ret = -1;
     $login = '';
     // Authentication mode
     if (empty($dolibarr_main_authentication)) {
         $dolibarr_main_authentication = 'http,dolibarr';
     }
     // Authentication mode: forceuser
     if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) {
         $dolibarr_auto_user = '******';
     }
     // Set authmode
     $authmode = explode(',', $dolibarr_main_authentication);
     // No authentication mode
     if (!sizeof($authmode) && empty($conf->login_method_modules)) {
         $langs->load('main');
         dol_print_error('', $langs->trans("ErrorConfigParameterNotDefined", 'dolibarr_main_authentication'));
         exit;
     }
     $test = true;
     // Validation of third party module login method
     if (is_array($conf->login_method_modules) && !empty($conf->login_method_modules)) {
         include_once DOL_DOCUMENT_ROOT . "/core/lib/security.lib.php";
         $login = getLoginMethod();
         if ($login) {
             $test = false;
         }
     }
     // Validation tests user / password
     // If ok, the variable will be initialized login
     // If error, we will put error message in session under the name dol_loginmesg
     $goontestloop = false;
     if (isset($_SERVER["REMOTE_USER"]) && in_array('http', $authmode)) {
         $goontestloop = true;
     }
     if (isset($aLogin) || GETPOST('openid_mode', 'alpha', 1)) {
         $goontestloop = true;
     }
     if ($test && $goontestloop) {
         foreach ($authmode as $mode) {
             if ($test && $mode && !$login) {
                 $authfile = DOL_DOCUMENT_ROOT . '/core/login/functions_' . $mode . '.php';
                 $result = (include_once $authfile);
                 if ($result) {
                     $this->login($aLogin);
                     $this->passwd($aPasswd);
                     $entitytotest = $conf->entity;
                     $function = 'check_user_password_' . $mode;
                     $login = $function($aLogin, $aPasswd, $entitytotest);
                     if ($login) {
                         $test = false;
                         $dol_authmode = $mode;
                         // This properties is defined only when logged to say what mode was successfully used
                         $ret = 0;
                     }
                 } else {
                     dol_syslog("Authentification ko - failed to load file '" . $authfile . "'", LOG_ERR);
                     sleep(1);
                     $ret = -1;
                 }
             }
         }
     }
     return $ret;
 }
示例#2
0
         $_SESSION["dol_loginmesg"] = $langs->trans("ErrorBadValueForCode");
         $test = false;
         // Appel des triggers
         include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php";
         $interface = new Interfaces($db);
         $result = $interface->run_triggers('USER_LOGIN_FAILED', $user, $user, $langs, $conf, GETPOST('entity'));
         if ($result < 0) {
             $error++;
         }
         // Fin appel triggers
     }
 }
 // Validation of login with a third party login module method
 if (is_array($conf->login_method_modules) && !empty($conf->login_method_modules)) {
     include_once DOL_DOCUMENT_ROOT . "/lib/security.lib.php";
     $login = getLoginMethod();
     if ($login) {
         $test = false;
     }
 }
 // Validation tests user / password
 // If ok, the variable will be initialized login
 // If error, we will put error message in session under the name dol_loginmesg
 $goontestloop = false;
 if (isset($_SERVER["REMOTE_USER"]) && in_array('http', $authmode)) {
     $goontestloop = true;
 }
 if (GETPOST("username", "alpha", 2) || GETPOST('openid_mode', 'alpha', 1)) {
     $goontestloop = true;
 }
 if ($test && $goontestloop) {