diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-07-25 19:53:11 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-07-25 19:53:11 +1200 |
commit | deb288877b8faa69c763c96ada7529380141af7f (patch) | |
tree | 6ae4210935ca851382d14a2388468811438677c5 /src/org/traccar/web/MainServlet.java | |
parent | e637bd7c022560dcc9c48516dc22a884a5de8122 (diff) | |
download | trackermap-server-deb288877b8faa69c763c96ada7529380141af7f.tar.gz trackermap-server-deb288877b8faa69c763c96ada7529380141af7f.tar.bz2 trackermap-server-deb288877b8faa69c763c96ada7529380141af7f.zip |
Update sessions user info
Diffstat (limited to 'src/org/traccar/web/MainServlet.java')
-rw-r--r-- | src/org/traccar/web/MainServlet.java | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/org/traccar/web/MainServlet.java b/src/org/traccar/web/MainServlet.java index eaadef245..21ef04088 100644 --- a/src/org/traccar/web/MainServlet.java +++ b/src/org/traccar/web/MainServlet.java @@ -15,8 +15,6 @@ */ package org.traccar.web; -import java.io.IOException; -import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.traccar.Context; @@ -46,10 +44,11 @@ public class MainServlet extends BaseServlet { return true; } - private void session(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - User user = (User) req.getSession().getAttribute(USER_KEY); - if (user != null) { - sendResponse(resp.getWriter(), JsonConverter.objectToJson(user)); + private void session(HttpServletRequest req, HttpServletResponse resp) throws Exception { + Long userId = (Long) req.getSession().getAttribute(USER_KEY); + if (userId != null) { + sendResponse(resp.getWriter(), JsonConverter.objectToJson( + Context.getDataManager().getUser(userId))); } else { sendResponse(resp.getWriter(), false); } @@ -59,7 +58,7 @@ public class MainServlet extends BaseServlet { User user = Context.getDataManager().login( req.getParameter("email"), req.getParameter("password")); if (user != null) { - req.getSession().setAttribute(USER_KEY, user); + req.getSession().setAttribute(USER_KEY, user.getId()); sendResponse(resp.getWriter(), JsonConverter.objectToJson(user)); } else { sendResponse(resp.getWriter(), false); |