X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Fpages%2Fmain%2FRegisterPage.java;h=e243c2875f92e826ac4ed21acb5adbaabed894b7;hb=5778f9cb59077a91b5fd56da88d56f378f771b1b;hp=b38194994bb69044907a3f3910feaae618482311;hpb=d463b3c42abe2f8edda3951580cf339dca6bb58e;p=gigi.git diff --git a/src/org/cacert/gigi/pages/main/RegisterPage.java b/src/org/cacert/gigi/pages/main/RegisterPage.java index b3819499..e243c287 100644 --- a/src/org/cacert/gigi/pages/main/RegisterPage.java +++ b/src/org/cacert/gigi/pages/main/RegisterPage.java @@ -8,6 +8,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import org.cacert.gigi.output.Form; import org.cacert.gigi.pages.Page; public class RegisterPage extends Page { @@ -20,44 +21,37 @@ public class RegisterPage extends Page { } @Override - public void doGet(HttpServletRequest req, HttpServletResponse resp) - throws IOException { + public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { + Signup s = new Signup(req); + outputGet(req, resp, s); + } + + private void outputGet(HttpServletRequest req, HttpServletResponse resp, Signup s) throws IOException { PrintWriter out = resp.getWriter(); HashMap vars = new HashMap(); getDefaultTemplate().output(out, getLanguage(req), vars); - Signup s = getForm(req); s.output(out, getLanguage(req), vars); } - public Signup getForm(HttpServletRequest req) { - HttpSession hs = req.getSession(); - Signup s = (Signup) hs.getAttribute(SIGNUP_PROCESS); - if (s == null) { - s = new Signup(); - hs.setAttribute(SIGNUP_PROCESS, s); - } - return s; - } @Override - public void doPost(HttpServletRequest req, HttpServletResponse resp) - throws IOException { - Signup s = getForm(req); - if (s.submit(resp.getWriter(), req)) { + public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { + Signup s = Form.getForm(req, Signup.class); + if (s == null) { + resp.getWriter().println(translate(req, "CSRF token check failed.")); + } else if (s.submit(resp.getWriter(), req)) { HttpSession hs = req.getSession(); hs.setAttribute(SIGNUP_PROCESS, null); - resp.getWriter() - .println( - translate( - req, - "Your information has been submitted" - + " into our system. You will now be sent an email with a web link," - + " you need to open that link in your web browser within 24 hours" - + " or your information will be removed from our system!")); + resp.getWriter().println( + translate(req, "Your information has been submitted" + + " into our system. You will now be sent an email with a web link," + + " you need to open that link in your web browser within 24 hours" + + " or your information will be removed from our system!")); return; } - super.doPost(req, resp); + outputGet(req, resp, s); } + @Override public boolean needsLogin() { return false;