diff options
author | Abyss777 <abyss@fox5.ru> | 2017-01-16 16:27:51 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-01-16 16:34:31 +0500 |
commit | 8a19ed9994e6bdd531faa3021711fc0e89497ca8 (patch) | |
tree | fa53e0b262be74b3bf4dd429219a4e20236493c9 /src/org/traccar/api/resource/UserPermissionResource.java | |
parent | b5eb48cbba215ca55c1a5e5ae5fae5b375243247 (diff) | |
download | trackermap-server-8a19ed9994e6bdd531faa3021711fc0e89497ca8.tar.gz trackermap-server-8a19ed9994e6bdd531faa3021711fc0e89497ca8.tar.bz2 trackermap-server-8a19ed9994e6bdd531faa3021711fc0e89497ca8.zip |
- Rename otherUserId to managedUserId
- Optimize getManaged* functions
Diffstat (limited to 'src/org/traccar/api/resource/UserPermissionResource.java')
-rw-r--r-- | src/org/traccar/api/resource/UserPermissionResource.java | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/org/traccar/api/resource/UserPermissionResource.java b/src/org/traccar/api/resource/UserPermissionResource.java index 35e22e6d4..a97c4a665 100644 --- a/src/org/traccar/api/resource/UserPermissionResource.java +++ b/src/org/traccar/api/resource/UserPermissionResource.java @@ -38,18 +38,17 @@ public class UserPermissionResource extends BaseResource { @POST public Response add(UserPermission entity) throws SQLException { Context.getPermissionsManager().checkAdmin(getUserId()); - if (entity.getUserId() == entity.getOtherUserId()) { - throw new SecurityException("Selfmanagement prohibited"); + if (entity.getUserId() != entity.getManagedUserId()) { + Context.getDataManager().linkUser(entity.getUserId(), entity.getManagedUserId()); + Context.getPermissionsManager().refreshUserPermissions(); } - Context.getDataManager().linkUser(entity.getUserId(), entity.getOtherUserId()); - Context.getPermissionsManager().refreshUserPermissions(); return Response.ok(entity).build(); } @DELETE public Response remove(UserPermission entity) throws SQLException { Context.getPermissionsManager().checkAdmin(getUserId()); - Context.getDataManager().unlinkUser(entity.getUserId(), entity.getOtherUserId()); + Context.getDataManager().unlinkUser(entity.getUserId(), entity.getManagedUserId()); Context.getPermissionsManager().refreshUserPermissions(); return Response.noContent().build(); } |