Skip to content
Snippets Groups Projects
Commit 3d30ebdb authored by Joseph AKEL's avatar Joseph AKEL Committed by Jean-Laurent DUZANT
Browse files

FIX #25530 02:45 Fix condition in UserController/getById() when usersGroups is...

FIX #25530 02:45 Fix condition in UserController/getById() when usersGroups is empty and in SignatureController/updateSubstituted() when checking global id and arg id
parent 56603577
No related branches found
No related tags found
No related merge requests found
......@@ -223,6 +223,10 @@ class SignatureController
return $response->withStatus(403)->withJson(['errors' => 'Privilege forbidden']);
}
if (!UserController::hasRightByUserId(['activeUserId' => $GLOBALS['id'], 'targetUserId' => $args['id']]) && $GLOBALS['id'] !== intval($args['id'])) {
return $response->withStatus(403)->withJson(['errors' => 'Privilege forbidden']);
}
$user = UserModel::getById(['select' => [1], 'id' => $args['id']]);
if (empty($user)) {
return $response->withStatus(400)->withJson(['errors' => 'User does not exist']);
......
......@@ -118,8 +118,10 @@ class UserController
if ($GLOBALS['id'] != $args['id']) {
$groupsIds = array_values(array_intersect($groupsIds, array_column(UserController::getManageableGroups(['userId' => $GLOBALS['id']]), 'id')));
}
$groups = GroupModel::get(['select' => ['label', 'id'], 'where' => ['id in (?)'], 'data' => [$groupsIds]]);
$user['groups'] = $groups;
if(!empty($groupsIds)){
$groups = GroupModel::get(['select' => ['label', 'id'], 'where' => ['id in (?)'], 'data' => [$groupsIds]]);
$user['groups'] = $groups;
}
} else {
$user = UserModel::getById(['select' => ['id', 'firstname', 'lastname', 'email', 'phone', 'substitute'], 'id' => $args['id']]);
}
......@@ -224,7 +226,7 @@ class UserController
if (!Validator::intVal()->notEmpty()->validate($args['id'])) {
return $response->withStatus(400)->withJson(['errors' => 'Route id is not an integer']);
}
$connection = ConfigurationModel::getConnection();
if (($GLOBALS['id'] != $args['id'] || $connection != 'default') && !UserController::hasRightByUserId(['activeUserId' => $GLOBALS['id'], 'targetUserId' => $args['id']])) {
return $response->withStatus(403)->withJson(['errors' => 'Privilege forbidden']);
......@@ -255,7 +257,7 @@ class UserController
'firstname' => $body['firstname'],
'lastname' => $body['lastname'],
'email' => $body['email'],
'phone' => $body['phone'] ?? null,
'phone' => $body['phone'] ?? null,
'signature_modes' => []
];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment