Skip to content
Snippets Groups Projects
Commit 0bcd0ed1 authored by nicolas lebozec's avatar nicolas lebozec
Browse files

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

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