diff options
Diffstat (limited to 'src/org/traccar/web/server')
-rw-r--r-- | src/org/traccar/web/server/model/DataServiceImpl.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/org/traccar/web/server/model/DataServiceImpl.java b/src/org/traccar/web/server/model/DataServiceImpl.java index 9c69b48e..01ab3164 100644 --- a/src/org/traccar/web/server/model/DataServiceImpl.java +++ b/src/org/traccar/web/server/model/DataServiceImpl.java @@ -55,7 +55,11 @@ public class DataServiceImpl extends RemoteServiceServlet implements DataService private void setUser(User user) { HttpSession session = getThreadLocalRequest().getSession(); - session.setAttribute(ATTRIBUTE_USER, user); + if (user != null) { + session.setAttribute(ATTRIBUTE_USER, user); + } else { + session.removeAttribute(ATTRIBUTE_USER); + } } private User getUser() { @@ -69,7 +73,7 @@ public class DataServiceImpl extends RemoteServiceServlet implements DataService } @Override - public boolean authenticate(String login, String password) { + public boolean login(String login, String password) { TypedQuery<User> query = entityManager.createQuery( "SELECT x FROM User x WHERE x.login = :login", User.class); query.setParameter("login", login); @@ -83,6 +87,12 @@ public class DataServiceImpl extends RemoteServiceServlet implements DataService } @Override + public boolean logout() { + setUser(null); + return true; + } + + @Override public boolean register(String login, String password) { User user = new User(); user.setLogin(login); |