aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/api
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-16 07:18:33 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-16 07:18:33 -0700
commitcc342a9ba371b0dca8d87ca9e74c5907ccb58bc6 (patch)
tree6d0354e4a357eb314eeaad044ad9591f9f98f867 /src/main/java/org/traccar/api
parentd3e83f9fa0d066e5a15fde225599cc43071c031a (diff)
downloadtrackermap-server-cc342a9ba371b0dca8d87ca9e74c5907ccb58bc6.tar.gz
trackermap-server-cc342a9ba371b0dca8d87ca9e74c5907ccb58bc6.tar.bz2
trackermap-server-cc342a9ba371b0dca8d87ca9e74c5907ccb58bc6.zip
Permissions manager refactor
Diffstat (limited to 'src/main/java/org/traccar/api')
-rw-r--r--src/main/java/org/traccar/api/resource/PermissionsResource.java5
-rw-r--r--src/main/java/org/traccar/api/resource/ServerResource.java4
2 files changed, 4 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/api/resource/PermissionsResource.java b/src/main/java/org/traccar/api/resource/PermissionsResource.java
index 36ee0c213..b92e6e9d9 100644
--- a/src/main/java/org/traccar/api/resource/PermissionsResource.java
+++ b/src/main/java/org/traccar/api/resource/PermissionsResource.java
@@ -20,6 +20,7 @@ import org.traccar.Context;
import org.traccar.api.BaseResource;
import org.traccar.helper.LogAction;
import org.traccar.model.Permission;
+import org.traccar.model.UserRestrictions;
import org.traccar.session.cache.CacheManager;
import org.traccar.storage.StorageException;
@@ -65,7 +66,7 @@ public class PermissionsResource extends BaseResource {
@Path("bulk")
@POST
public Response add(List<LinkedHashMap<String, Long>> entities) throws StorageException, ClassNotFoundException {
- Context.getPermissionsManager().checkReadonly(getUserId());
+ permissionsService.checkRestriction(getUserId(), UserRestrictions::getReadonly);
checkPermissionTypes(entities);
for (LinkedHashMap<String, Long> entity: entities) {
Permission permission = new Permission(entity);
@@ -90,7 +91,7 @@ public class PermissionsResource extends BaseResource {
@DELETE
@Path("bulk")
public Response remove(List<LinkedHashMap<String, Long>> entities) throws StorageException, ClassNotFoundException {
- Context.getPermissionsManager().checkReadonly(getUserId());
+ permissionsService.checkRestriction(getUserId(), UserRestrictions::getReadonly);
checkPermissionTypes(entities);
for (LinkedHashMap<String, Long> entity: entities) {
Permission permission = new Permission(entity);
diff --git a/src/main/java/org/traccar/api/resource/ServerResource.java b/src/main/java/org/traccar/api/resource/ServerResource.java
index 18230a2b3..b66f5a931 100644
--- a/src/main/java/org/traccar/api/resource/ServerResource.java
+++ b/src/main/java/org/traccar/api/resource/ServerResource.java
@@ -15,7 +15,6 @@
*/
package org.traccar.api.resource;
-import org.traccar.Context;
import org.traccar.api.BaseResource;
import org.traccar.database.MailManager;
import org.traccar.geocoder.Geocoder;
@@ -66,8 +65,7 @@ public class ServerResource extends BaseResource {
@PUT
public Response update(Server entity) throws StorageException {
- Context.getPermissionsManager().checkAdmin(getUserId());
- Context.getPermissionsManager().updateServer(entity);
+ permissionsService.checkAdmin(getUserId());
LogAction.edit(getUserId(), entity);
return Response.ok(entity).build();
}