]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/pages/main/RegisterPage.java
upd: use serials lowercase-only
[gigi.git] / src / org / cacert / gigi / pages / main / RegisterPage.java
index 1d43a75a135ae0cf56ebf4a6d5a702fb6c29eb8b..69dc4c1085062d042484c4e60f4730496b5c13ef 100644 (file)
@@ -1,14 +1,11 @@
 package org.cacert.gigi.pages.main;
 
 import java.io.IOException;
-import java.io.PrintWriter;
 import java.util.HashMap;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
 
-import org.cacert.gigi.GigiApiException;
 import org.cacert.gigi.output.template.Form;
 import org.cacert.gigi.pages.Page;
 import org.cacert.gigi.util.AuthorizationContext;
@@ -16,8 +13,6 @@ import org.cacert.gigi.util.RateLimit;
 
 public class RegisterPage extends Page {
 
-    private static final String SIGNUP_PROCESS = "signupProcess";
-
     public static final String PATH = "/register";
 
     // 50 per 5 min
@@ -34,27 +29,21 @@ public class RegisterPage extends Page {
     }
 
     private void outputGet(HttpServletRequest req, HttpServletResponse resp, Signup s) throws IOException {
-        PrintWriter out = resp.getWriter();
-        HashMap<String, Object> vars = new HashMap<String, Object>();
-        getDefaultTemplate().output(out, getLanguage(req), vars);
-        s.output(out, getLanguage(req), vars);
+        getDefaultTemplate().output(resp.getWriter(), getLanguage(req), new HashMap<String, Object>());
+        s.output(resp.getWriter(), getLanguage(req), new HashMap<String, Object>());
+    }
+
+    @Override
+    public boolean beforePost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
+        return Form.getForm(req, Signup.class).submitExceptionProtected(req, resp);
     }
 
     @Override
     public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
-        Signup s = Form.getForm(req, Signup.class);
-        try {
-            if (s.submit(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!"));
-                return;
-            }
-        } catch (GigiApiException e) {
-            e.format(resp.getWriter(), getLanguage(req));
+        if (Form.printFormErrors(req, resp.getWriter())) {
+            Signup s = Form.getForm(req, Signup.class);
+            outputGet(req, resp, s);
         }
-
-        outputGet(req, resp, s);
     }
 
     @Override