diff options
author | Abyss777 <abyss@fox5.ru> | 2017-08-01 17:23:24 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-08-01 17:31:15 +0500 |
commit | 75374d646e3fe848e00eb7b959b557c0ed0ade68 (patch) | |
tree | b14f9faebdee0e30a8ace2102939b23413ee2967 /src/org/traccar/database/UsersManager.java | |
parent | e400191c041b33284743b2303ab72721e831a0a3 (diff) | |
download | trackermap-server-75374d646e3fe848e00eb7b959b557c0ed0ade68.tar.gz trackermap-server-75374d646e3fe848e00eb7b959b557c0ed0ade68.tar.bz2 trackermap-server-75374d646e3fe848e00eb7b959b557c0ed0ade68.zip |
Fix retrieving objects by unknown tokens/uniqueId
Diffstat (limited to 'src/org/traccar/database/UsersManager.java')
-rw-r--r-- | src/org/traccar/database/UsersManager.java | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/org/traccar/database/UsersManager.java b/src/org/traccar/database/UsersManager.java index ed39f6cfa..576a9e6c7 100644 --- a/src/org/traccar/database/UsersManager.java +++ b/src/org/traccar/database/UsersManager.java @@ -25,7 +25,7 @@ import org.traccar.model.User; public class UsersManager extends SimpleObjectManager<User> { - private Map<String, Long> usersTokens; + private Map<String, User> usersTokens; public UsersManager(DataManager dataManager) { super(dataManager, User.class); @@ -39,7 +39,7 @@ public class UsersManager extends SimpleObjectManager<User> { usersTokens = new ConcurrentHashMap<>(); } if (user.getToken() != null) { - usersTokens.put(user.getToken(), user.getId()); + usersTokens.put(user.getToken(), user); } } @@ -53,9 +53,7 @@ public class UsersManager extends SimpleObjectManager<User> { protected void updateCachedItem(User user) { User cachedUser = getById(user.getId()); super.updateCachedItem(user); - if (user.getToken() != null) { - usersTokens.put(user.getToken(), user.getId()); - } + putToken(user); if (cachedUser.getToken() != null && !cachedUser.getToken().equals(user.getToken())) { usersTokens.remove(cachedUser.getToken()); } @@ -82,7 +80,7 @@ public class UsersManager extends SimpleObjectManager<User> { } public User getUserByToken(String token) { - return getById(usersTokens.get(token)); + return usersTokens.get(token); } } |