aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/api/resource
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-01-15 17:37:20 -0800
committerAnton Tananaev <anton@traccar.org>2023-01-15 17:37:30 -0800
commit1417098fa45a3060f17e0cca6d8226b12e7f174e (patch)
treec756c75b102dddb80e1b68190d24128727a3d96a /src/main/java/org/traccar/api/resource
parentdd25846efc91d53247f76b0afb8ee11b4fa8c341 (diff)
downloadtrackermap-server-1417098fa45a3060f17e0cca6d8226b12e7f174e.tar.gz
trackermap-server-1417098fa45a3060f17e0cca6d8226b12e7f174e.tar.bz2
trackermap-server-1417098fa45a3060f17e0cca6d8226b12e7f174e.zip
Remove default admin
Diffstat (limited to 'src/main/java/org/traccar/api/resource')
-rw-r--r--src/main/java/org/traccar/api/resource/ServerResource.java8
-rw-r--r--src/main/java/org/traccar/api/resource/SessionResource.java5
-rw-r--r--src/main/java/org/traccar/api/resource/UserResource.java5
3 files changed, 17 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/api/resource/ServerResource.java b/src/main/java/org/traccar/api/resource/ServerResource.java
index e7f0b93ca..4b7ee9189 100644
--- a/src/main/java/org/traccar/api/resource/ServerResource.java
+++ b/src/main/java/org/traccar/api/resource/ServerResource.java
@@ -16,6 +16,7 @@
package org.traccar.api.resource;
import org.traccar.api.BaseResource;
+import org.traccar.helper.model.UserUtil;
import org.traccar.mail.MailManager;
import org.traccar.geocoder.Geocoder;
import org.traccar.helper.Log;
@@ -65,6 +66,13 @@ public class ServerResource extends BaseResource {
server.setEmailEnabled(mailManager.getEmailEnabled());
server.setGeocoderEnabled(geocoder != null);
User user = permissionsService.getUser(getUserId());
+ if (user != null) {
+ if (user.getAdministrator()) {
+ server.setStorageSpace(Log.getStorageSpace());
+ }
+ } else {
+ server.setNewServer(UserUtil.isEmpty(storage));
+ }
if (user != null && user.getAdministrator()) {
server.setStorageSpace(Log.getStorageSpace());
}
diff --git a/src/main/java/org/traccar/api/resource/SessionResource.java b/src/main/java/org/traccar/api/resource/SessionResource.java
index 1e984fbd0..7025d5fa7 100644
--- a/src/main/java/org/traccar/api/resource/SessionResource.java
+++ b/src/main/java/org/traccar/api/resource/SessionResource.java
@@ -110,7 +110,10 @@ public class SessionResource extends BaseResource {
} else {
- return permissionsService.getUser(userId);
+ User user = permissionsService.getUser(userId);
+ if (user != null) {
+ return user;
+ }
}
diff --git a/src/main/java/org/traccar/api/resource/UserResource.java b/src/main/java/org/traccar/api/resource/UserResource.java
index 91875ef51..e41ebbe61 100644
--- a/src/main/java/org/traccar/api/resource/UserResource.java
+++ b/src/main/java/org/traccar/api/resource/UserResource.java
@@ -19,6 +19,7 @@ import org.traccar.api.BaseObjectResource;
import org.traccar.config.Config;
import org.traccar.config.Keys;
import org.traccar.helper.LogAction;
+import org.traccar.helper.model.UserUtil;
import org.traccar.model.ManagedUser;
import org.traccar.model.Permission;
import org.traccar.model.User;
@@ -98,6 +99,10 @@ public class UserResource extends BaseObjectResource<User> {
}
}
+ if (UserUtil.isEmpty(storage)) {
+ entity.setAdministrator(true);
+ }
+
entity.setId(storage.addObject(entity, new Request(new Columns.Exclude("id"))));
storage.updateObject(entity, new Request(
new Columns.Include("hashedPassword", "salt"),