forked from Wavyzz/dolibarr
Merge pull request #10341 from hregis/8.0_bug
FIX security broken with Multicompany
This commit is contained in:
@@ -252,6 +252,7 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu
|
||||
$tmpreadok=1;
|
||||
foreach($feature2 as $subfeature)
|
||||
{
|
||||
if ($subfeature == 'user' && $user->id == $objectid) continue; // A user can always read its own card
|
||||
if (! empty($subfeature) && empty($user->rights->$feature->$subfeature->lire) && empty($user->rights->$feature->$subfeature->read)) { $tmpreadok=0; }
|
||||
else if (empty($subfeature) && empty($user->rights->$feature->lire) && empty($user->rights->$feature->read)) { $tmpreadok=0; }
|
||||
else { $tmpreadok=1; break; } // Break is to bypass second test if the first is ok
|
||||
|
||||
@@ -57,10 +57,7 @@ $object->getrights();
|
||||
$socid=0;
|
||||
if ($user->societe_id > 0) $socid = $user->societe_id;
|
||||
$feature2 = (($socid && $user->rights->user->self->creer)?'':'user');
|
||||
if ($user->id == $id) // A user can always read its own card
|
||||
{
|
||||
$feature2='';
|
||||
}
|
||||
|
||||
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
|
||||
|
||||
// If user is not user that read and no permission to read other users, we stop
|
||||
|
||||
@@ -85,11 +85,8 @@ if ($id)
|
||||
$socid=0;
|
||||
if ($user->societe_id > 0) $socid = $user->societe_id;
|
||||
$feature2='user';
|
||||
if ($user->id == $id) { $feature2=''; $canreaduser=1; } // A user can always read its own card
|
||||
|
||||
if (! $canreaduser) {
|
||||
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
|
||||
}
|
||||
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
|
||||
|
||||
if ($user->id <> $id && ! $canreaduser) accessforbidden();
|
||||
|
||||
|
||||
@@ -35,10 +35,7 @@ $id=GETPOST('id','int');
|
||||
$socid=0;
|
||||
if ($user->societe_id > 0) $socid = $user->societe_id;
|
||||
$feature2 = (($socid && $user->rights->user->self->creer)?'':'user');
|
||||
if ($user->id == $id) // A user can always read its own card
|
||||
{
|
||||
$feature2='';
|
||||
}
|
||||
|
||||
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
|
||||
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
|
||||
@@ -66,10 +66,9 @@ if ($id)
|
||||
$socid=0;
|
||||
if ($user->societe_id > 0) $socid = $user->societe_id;
|
||||
$feature2='user';
|
||||
if ($user->id == $id) { $feature2=''; $canreaduser=1; } // A user can always read its own card
|
||||
if (!$canreaduser) {
|
||||
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
|
||||
}
|
||||
|
||||
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
|
||||
|
||||
if ($user->id <> $id && ! $canreaduser) accessforbidden();
|
||||
|
||||
// Get parameters
|
||||
|
||||
@@ -43,10 +43,7 @@ if ($id > 0 || ! empty($ref))
|
||||
$socid=0;
|
||||
if ($user->societe_id > 0) $socid = $user->societe_id;
|
||||
$feature2 = (($socid && $user->rights->user->self->creer)?'':'user');
|
||||
if ($user->id == $id) // A user can always read its own card
|
||||
{
|
||||
$feature2='';
|
||||
}
|
||||
|
||||
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
|
||||
|
||||
// If user is not user that read and no permission to read other users, we stop
|
||||
|
||||
@@ -37,7 +37,7 @@ $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'userldap';
|
||||
$socid=0;
|
||||
if ($user->societe_id > 0) $socid = $user->societe_id;
|
||||
$feature2 = (($socid && $user->rights->user->self->creer)?'':'user');
|
||||
if ($user->id == $id) $feature2=''; // A user can always read its own card
|
||||
|
||||
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
|
||||
|
||||
$object = new User($db);
|
||||
|
||||
@@ -45,7 +45,7 @@ if (($object->id != $user->id) && (! $user->rights->user->user->lire)) accessfor
|
||||
$socid=0;
|
||||
if ($user->societe_id > 0) $socid = $user->societe_id;
|
||||
$feature2 = (($socid && $user->rights->user->self->creer)?'':'user');
|
||||
if ($user->id == $id) $feature2=''; // A user can always read its own card
|
||||
|
||||
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
|
||||
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
|
||||
@@ -49,11 +49,7 @@ if ($id)
|
||||
$socid=0;
|
||||
if ($user->societe_id > 0) $socid = $user->societe_id;
|
||||
$feature2 = (($socid && $user->rights->user->self->creer)?'':'user');
|
||||
if ($user->id == $id) // A user can always read its own card
|
||||
{
|
||||
$feature2='';
|
||||
$canreaduser=1;
|
||||
}
|
||||
|
||||
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
|
||||
if ($user->id <> $id && ! $canreaduser) accessforbidden();
|
||||
|
||||
|
||||
@@ -58,10 +58,9 @@ if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS))
|
||||
$socid=0;
|
||||
if (isset($user->societe_id) && $user->societe_id > 0) $socid = $user->societe_id;
|
||||
$feature2 = (($socid && $user->rights->user->self->creer)?'':'user');
|
||||
if ($user->id == $id && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->user->self_advance->readperms)) // A user can always read its own card if not advanced perms enabled, or if he has advanced perms
|
||||
if ($user->id == $id && (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->user->self_advance->readperms))) // A user can always read its own card if not advanced perms enabled, or if he has advanced perms
|
||||
{
|
||||
$feature2='';
|
||||
$canreaduser=1;
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
|
||||
|
||||
Reference in New Issue
Block a user