]> WPIA git - gigi.git/blob - src/org/cacert/gigi/pages/main/RegisterPage.java
Format code according do BenBE's formatter.
[gigi.git] / src / org / cacert / gigi / pages / main / RegisterPage.java
1 package org.cacert.gigi.pages.main;
2
3 import java.io.IOException;
4 import java.io.PrintWriter;
5 import java.util.HashMap;
6
7 import javax.servlet.http.HttpServletRequest;
8 import javax.servlet.http.HttpServletResponse;
9 import javax.servlet.http.HttpSession;
10
11 import org.cacert.gigi.output.Form;
12 import org.cacert.gigi.pages.Page;
13
14 public class RegisterPage extends Page {
15
16     private static final String SIGNUP_PROCESS = "signupProcess";
17
18     public static final String PATH = "/register";
19
20     public RegisterPage() {
21         super("Register");
22     }
23
24     @Override
25     public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
26         Signup s = new Signup(req);
27         outputGet(req, resp, s);
28     }
29
30     private void outputGet(HttpServletRequest req, HttpServletResponse resp, Signup s) throws IOException {
31         PrintWriter out = resp.getWriter();
32         HashMap<String, Object> vars = new HashMap<String, Object>();
33         getDefaultTemplate().output(out, getLanguage(req), vars);
34         s.output(out, getLanguage(req), vars);
35     }
36
37     @Override
38     public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
39         Signup s = Form.getForm(req, Signup.class);
40         if (s == null) {
41             resp.getWriter().println(translate(req, "CSRF token check failed."));
42         } else if (s.submit(resp.getWriter(), req)) {
43             HttpSession hs = req.getSession();
44             hs.setAttribute(SIGNUP_PROCESS, null);
45             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!"));
46             return;
47         }
48
49         outputGet(req, resp, s);
50     }
51
52     @Override
53     public boolean needsLogin() {
54         return false;
55     }
56 }