Skip to content
Snippets Groups Projects
Commit ffdcda85 authored by nicolas lebozec's avatar nicolas lebozec Committed by Guillaume Heurtier
Browse files

FIX #22934 TIME 0:20 Add check if getUserInformationsById is empty

parent 5facc532
No related branches found
No related tags found
No related merge requests found
......@@ -106,8 +106,12 @@ class UserController
return $response->withStatus(400)->withJson(['errors' => 'Route id is not an integer']);
}
if ($GLOBALS['id'] == $args['id'] || PrivilegeController::hasPrivilege(['userId' => $GLOBALS['id'], 'privilege' => 'manage_users'])) {
$user = UserController::getUserInformationsById(['id' => $args['id']]);
if (empty($user)) {
return $response->withStatus(400)->withJson(['errors' => 'User does not exist']);
}
$user['groups'] = [];
$userGroups = UserGroupModel::get(['select' => ['group_id'], 'where' => ['user_id = ?'], 'data' => [$args['id']]]);
$groupsIds = array_column($userGroups, 'group_id');
......@@ -119,7 +123,6 @@ class UserController
} else {
$user = UserModel::getById(['select' => ['id', 'firstname', 'lastname', 'email', 'phone', 'substitute'], 'id' => $args['id']]);
}
if (empty($user)) {
return $response->withStatus(400)->withJson(['errors' => 'User does not exist']);
}
......
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