aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
authorShinryuken <watertext@hotmail.it>2017-11-07 19:12:37 +0100
committerGitHub <noreply@github.com>2017-11-07 19:12:37 +0100
commit5117b2e64781161c9e06f57cbee217f174d5731e (patch)
treeb5e0a4c6578bd1d7123730cbafc4405a7bfc7b7b /src/org
parent80904fd5794b1eb3ef7644c52ce3d09facf9fd04 (diff)
downloadtraccar-server-5117b2e64781161c9e06f57cbee217f174d5731e.tar.gz
traccar-server-5117b2e64781161c9e06f57cbee217f174d5731e.tar.bz2
traccar-server-5117b2e64781161c9e06f57cbee217f174d5731e.zip
User defaults when no User is available
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/database/PermissionsManager.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/org/traccar/database/PermissionsManager.java b/src/org/traccar/database/PermissionsManager.java
index 07b60ba58..203f25a3d 100644
--- a/src/org/traccar/database/PermissionsManager.java
+++ b/src/org/traccar/database/PermissionsManager.java
@@ -56,8 +56,8 @@ public class PermissionsManager {
refreshDeviceAndGroupPermissions();
}
- public User getUser(long userId) {
- return (User) usersManager.getById(userId);
+ public User getUser(Long userId) {
+ return userId != null ? (User) usersManager.getById(userId) : null;
}
public Set<Long> getGroupPermissions(long userId) {
@@ -416,10 +416,15 @@ public class PermissionsManager {
return null;
}
- public Object lookupAttribute(long userId, String key, Object defaultValue) {
+ public Object lookupAttribute(Long userId, String key, Object defaultValue) {
Object preference;
+ Object userPreference = null;
Object serverPreference = server.getAttributes().get(key);
- Object userPreference = getUser(userId).getAttributes().get(key);
+
+ if (userId != null) {
+ userPreference = getUser(userId).getAttributes().get(key);
+ }
+
if (server.getForceSettings()) {
preference = serverPreference != null ? serverPreference : userPreference;
} else {