Merge pull request #2492 from IonAgorria/mc-fix

Fix: Check if $mc is a valid global
This commit is contained in:
Laurent Destailleur 2015-03-28 18:20:28 +01:00
commit 4887a28f91

View File

@ -111,15 +111,22 @@ function check_user_password_dolibarr($usertotest,$passwordtotest,$entitytotest=
$_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadLoginPassword"); $_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadLoginPassword");
} }
if ($passok && ! empty($conf->multicompany->enabled)) // We must check entity // We must check entity
if ($passok)
{ {
global $mc; global $mc;
$ret=$mc->checkRight($obj->rowid, $entitytotest); if (!isset($mc)) {
if ($ret < 0) //Global not available, disable $conf->multicompany->enabled for safety
{ $conf->multicompany->enabled = false;
dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko entity '".$entitytotest."' not allowed for user '".$obj->rowid."'"); }
$login=''; // force authentication failure
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
}
} }
} }
} }