aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/web/server/model
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2013-01-11 19:48:19 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2013-01-11 19:48:19 +1300
commit47cea42e319176aa69decc43e8d8074374ff0c4b (patch)
tree604850f3300e00bdd3a33735338949f2a9d39dfe /src/org/traccar/web/server/model
parent3defcd30d7ef7c10c82561b955c9e4e4fba789bf (diff)
downloadtrackermap-web-47cea42e319176aa69decc43e8d8074374ff0c4b.tar.gz
trackermap-web-47cea42e319176aa69decc43e8d8074374ff0c4b.tar.bz2
trackermap-web-47cea42e319176aa69decc43e8d8074374ff0c4b.zip
Add logout button
Diffstat (limited to 'src/org/traccar/web/server/model')
-rw-r--r--src/org/traccar/web/server/model/DataServiceImpl.java14
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);