From 043d11d78564ee0fb5c286e5ba4e4963eea93d79 Mon Sep 17 00:00:00 2001 From: Ion Agorria Date: Sat, 28 Mar 2015 03:44:16 +0100 Subject: [PATCH] check if $mc is a valid global --- htdocs/core/login/functions_dolibarr.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/htdocs/core/login/functions_dolibarr.php b/htdocs/core/login/functions_dolibarr.php index 69aec814413..8654c866969 100644 --- a/htdocs/core/login/functions_dolibarr.php +++ b/htdocs/core/login/functions_dolibarr.php @@ -111,15 +111,22 @@ function check_user_password_dolibarr($usertotest,$passwordtotest,$entitytotest= $_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadLoginPassword"); } - if ($passok && ! empty($conf->multicompany->enabled)) // We must check entity + // We must check entity + if ($passok) { global $mc; - $ret=$mc->checkRight($obj->rowid, $entitytotest); - if ($ret < 0) - { - dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko entity '".$entitytotest."' not allowed for user '".$obj->rowid."'"); - $login=''; // force authentication failure + if (!isset($mc)) { + //Global not available, disable $conf->multicompany->enabled for safety + $conf->multicompany->enabled = false; + } + + if (! empty($conf->multicompany->enabled)) { + $ret = $mc->checkRight($obj->rowid, $entitytotest); + if ($ret < 0) { + dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko entity '" . $entitytotest . "' not allowed for user '" . $obj->rowid . "'"); + $login = ''; // force authentication failure + } } } }