X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Fpages%2FLoginPage.java;h=583a6da88168dd380ab70e3864f6bd94e2613d47;hp=49b42dbe264c3a7a47ab01fa1e8f89c8ca3d49b6;hb=dc71766639ada349bb35f676ad811eb113311d4c;hpb=ea6ee43a84f9a1f055d97ff0de8196569154e4d0 diff --git a/src/org/cacert/gigi/pages/LoginPage.java b/src/org/cacert/gigi/pages/LoginPage.java index 49b42dbe..583a6da8 100644 --- a/src/org/cacert/gigi/pages/LoginPage.java +++ b/src/org/cacert/gigi/pages/LoginPage.java @@ -18,6 +18,8 @@ import org.cacert.gigi.database.DatabaseConnection; import org.cacert.gigi.util.PasswordHash; public class LoginPage extends Page { + public static final String LOGIN_RETURNPATH = "login-returnpath"; + public LoginPage(String title) { super(title); } @@ -25,6 +27,16 @@ public class LoginPage extends Page { @Override public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { + resp.getWriter() + .println( + "
" + + "" + + "
"); + } + + @Override + public boolean beforeTemplate(HttpServletRequest req, + HttpServletResponse resp) throws IOException { HttpSession hs = req.getSession(); if (hs.getAttribute("loggedin") == null) { X509Certificate[] cert = (X509Certificate[]) req @@ -37,16 +49,19 @@ public class LoginPage extends Page { } } - if (hs.getAttribute("loggedin") != null) { // Redir from login - resp.sendRedirect("/"); - return; + if (hs.getAttribute("loggedin") != null) { + String s = (String) req.getSession().getAttribute(LOGIN_RETURNPATH); + if (s != null) { + if (!s.startsWith("/")) { + s = "/" + s; + } + resp.sendRedirect(s); + } else { + resp.sendRedirect("/"); + } + return true; } - - resp.getWriter() - .println( - "
" - + "" - + "
"); + return false; } @Override public boolean needsLogin() {