aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/api/resource/DeviceResource.java2
-rw-r--r--src/org/traccar/database/PermissionsManager.java8
2 files changed, 8 insertions, 2 deletions
diff --git a/src/org/traccar/api/resource/DeviceResource.java b/src/org/traccar/api/resource/DeviceResource.java
index c432a04f4..c04b3b474 100644
--- a/src/org/traccar/api/resource/DeviceResource.java
+++ b/src/org/traccar/api/resource/DeviceResource.java
@@ -88,7 +88,7 @@ public class DeviceResource extends BaseObjectResource<Device> {
@Path("{id}/distance")
@PUT
public Response updateTotalDistance(DeviceTotalDistance entity) throws SQLException {
- Context.getPermissionsManager().checkDevice(getUserId(), entity.getDeviceId());
+ Context.getPermissionsManager().checkDeviceManagerOrAdmin(getUserId(), entity.getDeviceId());
Context.getDeviceManager().resetTotalDistance(entity);
LogAction.resetTotalDistance(getUserId(), entity.getDeviceId());
return Response.noContent().build();
diff --git a/src/org/traccar/database/PermissionsManager.java b/src/org/traccar/database/PermissionsManager.java
index 60bda99ce..05806175c 100644
--- a/src/org/traccar/database/PermissionsManager.java
+++ b/src/org/traccar/database/PermissionsManager.java
@@ -300,7 +300,13 @@ public class PermissionsManager {
}
public void checkDevice(long userId, long deviceId) throws SecurityException {
- if (!Context.getDeviceManager().getUserItems(userId).contains(deviceId) && !getUserAdmin(userId)) {
+ if (!Context.getDeviceManager().getUserItems(userId).contains(deviceId)) {
+ checkDeviceManagerOrAdmin(userId, deviceId);
+ }
+ }
+
+ public void checkDeviceManagerOrAdmin(long userId, long deviceId) throws SecurityException {
+ if (!getUserAdmin(userId)) {
checkManager(userId);
for (long managedUserId : usersManager.getUserItems(userId)) {
if (Context.getDeviceManager().getUserItems(managedUserId).contains(deviceId)) {