X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;ds=sidebyside;f=src%2Forg%2Fcacert%2Fgigi%2Fpages%2FLoginPage.java;h=b19de897aa5e7b3f71f9ba122d1fb70a00938696;hb=17a15662212d973d12ed4cea3f5eaa9c0d1169ed;hp=c206ad444df43c5b0df0a08e4add6612fda6f5c4;hpb=2f50dbb24105e6345329b8e9ecb5ef4d67ab2a8c;p=gigi.git diff --git a/src/org/cacert/gigi/pages/LoginPage.java b/src/org/cacert/gigi/pages/LoginPage.java index c206ad44..b19de897 100644 --- a/src/org/cacert/gigi/pages/LoginPage.java +++ b/src/org/cacert/gigi/pages/LoginPage.java @@ -39,7 +39,7 @@ public class LoginPage extends Page { } @Override - public boolean submit(PrintWriter out, HttpServletRequest req) throws GigiApiException { + public boolean submit(HttpServletRequest req) throws GigiApiException { if (RegisterPage.RATE_LIMIT.isLimitExceeded(req.getRemoteAddr())) { throw new RateLimitException(); } @@ -64,10 +64,6 @@ public class LoginPage extends Page { @Override public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { - Object o = req.getAttribute(SUBMIT_EXCEPTION); - if (o != null) { - ((GigiApiException) o).format(resp.getWriter(), getLanguage(req)); - } if (req.getHeader("Host").equals(ServerConstants.getSecureHostNamePort())) { resp.getWriter().println(getLanguage(req).getTranslation("Authentication with certificate failed. Try another certificate or use a password.")); } else { @@ -75,6 +71,13 @@ public class LoginPage extends Page { } } + @Override + public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { + if (Form.printFormErrors(req, resp.getWriter())) { + Form.getForm(req, LoginForm.class).output(resp.getWriter(), getLanguage(req), new HashMap()); + } + } + @Override public boolean beforeTemplate(HttpServletRequest req, HttpServletResponse resp) throws IOException { String redir = (String) req.getSession().getAttribute(LOGIN_RETURNPATH); @@ -84,10 +87,7 @@ public class LoginPage extends Page { tryAuthWithCertificate(req, cert); } if (req.getMethod().equals("POST")) { - try { - Form.getForm(req, LoginForm.class).submit(resp.getWriter(), req); - } catch (GigiApiException e) { - req.setAttribute(SUBMIT_EXCEPTION, e); + if ( !Form.getForm(req, LoginForm.class).submitExceptionProtected(req)) { return false; } } @@ -188,7 +188,7 @@ public class LoginPage extends Page { return uc; } - private static final Group LOGIN_BLOCKED = Group.getByString("blockedlogin"); + private static final Group LOGIN_BLOCKED = Group.BLOCKEDLOGIN; private void loginSession(HttpServletRequest req, User user) { if (user.isInGroup(LOGIN_BLOCKED)) {