aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/web/server/model/DataServiceImpl.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2013-02-20 23:58:19 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2013-02-20 23:58:19 +1300
commitb26e487f3c65808d349c7a53c0ea2a3981b61bac (patch)
tree57873f966be2953f3cb6b6f518cd44ea1adf720c /src/org/traccar/web/server/model/DataServiceImpl.java
parent6801698dfc9c99b34d7ed081ebcfbec4a8853868 (diff)
downloadtrackermap-web-b26e487f3c65808d349c7a53c0ea2a3981b61bac.tar.gz
trackermap-web-b26e487f3c65808d349c7a53c0ea2a3981b61bac.tar.bz2
trackermap-web-b26e487f3c65808d349c7a53c0ea2a3981b61bac.zip
Add user preferences
Diffstat (limited to 'src/org/traccar/web/server/model/DataServiceImpl.java')
-rw-r--r--src/org/traccar/web/server/model/DataServiceImpl.java27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/org/traccar/web/server/model/DataServiceImpl.java b/src/org/traccar/web/server/model/DataServiceImpl.java
index 1f6ff608..c2d9f72e 100644
--- a/src/org/traccar/web/server/model/DataServiceImpl.java
+++ b/src/org/traccar/web/server/model/DataServiceImpl.java
@@ -102,8 +102,8 @@ public class DataServiceImpl extends RemoteServiceServlet implements DataService
}
@Override
- public boolean authenticated() {
- return (getUser() != null);
+ public User authenticated() {
+ return getUser();
}
@Override
@@ -152,19 +152,20 @@ public class DataServiceImpl extends RemoteServiceServlet implements DataService
if (currentUser.getAdmin() || (currentUser.getId() == user.getId() && !user.getAdmin())) {
EntityManager entityManager = entityManagerFactory.createEntityManager();
try {
- // TODO: better solution?
- if (currentUser.getId() == user.getId()) {
- currentUser.setLogin(user.getLogin());
- currentUser.setPassword(user.getPassword());
- currentUser.setUserSettings(user.getUserSettings());
- user = currentUser;
- } else {
- // TODO: handle other users
- }
-
entityManager.getTransaction().begin();
try {
- entityManager.merge(user);
+ // TODO: better solution?
+ if (currentUser.getId() == user.getId()) {
+ entityManager.merge(currentUser);
+ currentUser.setLogin(user.getLogin());
+ currentUser.setPassword(user.getPassword());
+ currentUser.setUserSettings(user.getUserSettings());
+ entityManager.merge(currentUser);
+ user = currentUser;
+ } else {
+ // TODO: handle other users
+ }
+
entityManager.getTransaction().commit();
setUser(user);
return user;