check if $mc is a valid global

This commit is contained in:
Ion Agorria 2015-03-28 03:44:16 +01:00 committed by Laurent Destailleur
parent 3f5fe432e7
commit 043d11d785

View File

@ -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
}
}
}
}