]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/pages/main/RegisterPage.java
upd: better display of (and collection of) error messages
[gigi.git] / src / org / cacert / gigi / pages / main / RegisterPage.java
index 1e6b33783ee3b89c47c3e602cb90b0196bb949a8..30c428333702991664e451aa3dc6b9b9452d32d7 100644 (file)
@@ -8,6 +8,7 @@ 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;
@@ -42,13 +43,15 @@ public class RegisterPage extends Page {
     @Override
     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!"));
-            return;
+        try {
+            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!"));
+                return;
+            }
+        } catch (GigiApiException e) {
+            e.format(resp.getWriter(), getLanguage(req));
         }
 
         outputGet(req, resp, s);