From 8686fbe48d485be94b63e723258f19ef93abcaad Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 1 Jan 2016 20:40:45 +1300 Subject: Always allow admin to register new users --- src/org/traccar/api/resource/UserResource.java | 4 +++- src/org/traccar/database/PermissionsManager.java | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/org/traccar/api/resource/UserResource.java b/src/org/traccar/api/resource/UserResource.java index 4d57d5b0c..9eb0d9597 100644 --- a/src/org/traccar/api/resource/UserResource.java +++ b/src/org/traccar/api/resource/UserResource.java @@ -47,7 +47,9 @@ public class UserResource extends BaseResource { @PermitAll @POST public Response add(User entity) throws SQLException { - Context.getPermissionsManager().checkRegistration(getUserId()); + if (!Context.getPermissionsManager().isAdmin(getUserId())) { + Context.getPermissionsManager().checkRegistration(getUserId()); + } Context.getDataManager().addUser(entity); Context.getPermissionsManager().refresh(); return Response.ok(entity).build(); diff --git a/src/org/traccar/database/PermissionsManager.java b/src/org/traccar/database/PermissionsManager.java index b0f544a42..5557f37e5 100644 --- a/src/org/traccar/database/PermissionsManager.java +++ b/src/org/traccar/database/PermissionsManager.java @@ -64,7 +64,7 @@ public class PermissionsManager { } } - private boolean isAdmin(long userId) { + public boolean isAdmin(long userId) { return users.containsKey(userId) && users.get(userId).getAdmin(); } -- cgit v1.2.3