diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-04-29 23:29:43 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-04-29 23:29:43 +1200 |
commit | 8e6e361eb0e1d4c92b99fa20a70f0fa7b296a466 (patch) | |
tree | 9a1a69460652a0da7507c5fc2dec724290e30845 /src/org/traccar | |
parent | 2b0610469c10f99dd21393cbbed81a9d0d06b868 (diff) | |
download | trackermap-server-8e6e361eb0e1d4c92b99fa20a70f0fa7b296a466.tar.gz trackermap-server-8e6e361eb0e1d4c92b99fa20a70f0fa7b296a466.tar.bz2 trackermap-server-8e6e361eb0e1d4c92b99fa20a70f0fa7b296a466.zip |
Check if user is logged in
Diffstat (limited to 'src/org/traccar')
-rw-r--r-- | src/org/traccar/http/MainServlet.java | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/org/traccar/http/MainServlet.java b/src/org/traccar/http/MainServlet.java index 10920accb..4dc02e81f 100644 --- a/src/org/traccar/http/MainServlet.java +++ b/src/org/traccar/http/MainServlet.java @@ -53,6 +53,8 @@ public class MainServlet extends HttpServlet { resp.sendError(HttpServletResponse.SC_BAD_REQUEST); } else if (command.equals("/async")) { async(req.startAsync()); + } else if (command.equals("/session")) { + session(req, resp); } else if (command.equals("/login")) { login(req, resp); } else if (command.equals("/logout")) { @@ -211,6 +213,10 @@ public class MainServlet extends HttpServlet { } } + private void session(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + resp.getWriter().println("{ success: true, session: " + (req.getSession().getAttribute(USER_ID) != null) + " }"); + } + private void login(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try { req.getSession().setAttribute(USER_ID, |