aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2023-05-28 18:00:43 -0700
committerGitHub <noreply@github.com>2023-05-28 18:00:43 -0700
commitf469e52c72b3fca6f4bff8667e1e3095f2a265f2 (patch)
tree055cf8c0d1253e53fc198b4cf5e64dd3d2a492cc /src
parent671e8fbdfd90dce91f372750105561fa7d3b472c (diff)
parent729df52ea52ce5807b6328eb04cf55d3e9cbea81 (diff)
downloadtrackermap-server-f469e52c72b3fca6f4bff8667e1e3095f2a265f2.tar.gz
trackermap-server-f469e52c72b3fca6f4bff8667e1e3095f2a265f2.tar.bz2
trackermap-server-f469e52c72b3fca6f4bff8667e1e3095f2a265f2.zip
Merge pull request #5096 from merabtenei/serviceAccount-allow-create
do not add permission if user is serviceAccount
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/api/BaseObjectResource.java12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/api/BaseObjectResource.java b/src/main/java/org/traccar/api/BaseObjectResource.java
index 904781e54..b007b7bcd 100644
--- a/src/main/java/org/traccar/api/BaseObjectResource.java
+++ b/src/main/java/org/traccar/api/BaseObjectResource.java
@@ -16,6 +16,7 @@
*/
package org.traccar.api;
+import org.traccar.api.security.ServiceAccountUser;
import org.traccar.helper.LogAction;
import org.traccar.model.BaseModel;
import org.traccar.model.Group;
@@ -70,10 +71,13 @@ public abstract class BaseObjectResource<T extends BaseModel> extends BaseResour
entity.setId(storage.addObject(entity, new Request(new Columns.Exclude("id"))));
LogAction.create(getUserId(), entity);
- storage.addPermission(new Permission(User.class, getUserId(), baseClass, entity.getId()));
- cacheManager.invalidatePermission(true, User.class, getUserId(), baseClass, entity.getId());
- connectionManager.invalidatePermission(true, User.class, getUserId(), baseClass, entity.getId());
- LogAction.link(getUserId(), User.class, getUserId(), baseClass, entity.getId());
+
+ if (getUserId() != ServiceAccountUser.ID) {
+ storage.addPermission(new Permission(User.class, getUserId(), baseClass, entity.getId()));
+ cacheManager.invalidatePermission(true, User.class, getUserId(), baseClass, entity.getId());
+ connectionManager.invalidatePermission(true, User.class, getUserId(), baseClass, entity.getId());
+ LogAction.link(getUserId(), User.class, getUserId(), baseClass, entity.getId());
+ }
return Response.ok(entity).build();
}