GUAC-962: Do not attempt to query users unless absolutely necessary.
This commit is contained in:
1 parent
bdf41b2c65
commit
c7485fb3c3
1 file changed
+12
-4
+12
-4
@@ -325,10 +325,18 @@ public class UserRESTService {
|
|||||||
|
|
||||||
UserContext userContext = authenticationService.getUserContext(authToken);
|
UserContext userContext = authenticationService.getUserContext(authToken);
|
||||||
|
|
||||||
// Get the user
|
User user;
|
||||||
User user = userContext.getUserDirectory().get(username);
|
|
||||||
if (user == null)
|
// If username is own username, just use self - might not have query permissions
|
||||||
throw new GuacamoleResourceNotFoundException("No such user: \"" + username + "\"");
|
if (userContext.self().getUsername().equals(username))
|
||||||
|
user = userContext.self();
|
||||||
|
|
||||||
|
// If not self, query corresponding user from directory
|
||||||
|
else {
|
||||||
|
user = userContext.getUserDirectory().get(username);
|
||||||
|
if (user == null)
|
||||||
|
throw new GuacamoleResourceNotFoundException("No such user: \"" + username + "\"");
|
||||||
|
}
|
||||||
|
|
||||||
return new APIPermissionSet(user.getPermissions());
|
return new APIPermissionSet(user.getPermissions());
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user