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,18 +111,25 @@ 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;
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); $ret = $mc->checkRight($obj->rowid, $entitytotest);
if ($ret < 0) if ($ret < 0) {
{
dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko entity '" . $entitytotest . "' not allowed for user '" . $obj->rowid . "'"); dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko entity '" . $entitytotest . "' not allowed for user '" . $obj->rowid . "'");
$login = ''; // force authentication failure $login = ''; // force authentication failure
} }
} }
} }
}
else else
{ {
dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko user not found for '".$usertotest."'"); dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko user not found for '".$usertotest."'");