]> WPIA git - gigi.git/blob - src/org/cacert/gigi/pages/main/RegisterPage.java
[EMPTY] Formatting with configured 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.pages.Page;
12
13 public class RegisterPage extends Page {
14
15         private static final String SIGNUP_PROCESS = "signupProcess";
16         public static final String PATH = "/register";
17
18         public RegisterPage() {
19                 super("Register");
20         }
21
22         @Override
23         public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
24                 PrintWriter out = resp.getWriter();
25                 HashMap<String, Object> vars = new HashMap<String, Object>();
26                 getDefaultTemplate().output(out, getLanguage(req), vars);
27                 Signup s = getForm(req);
28                 s.output(out, getLanguage(req), vars);
29         }
30
31         public Signup getForm(HttpServletRequest req) {
32                 HttpSession hs = req.getSession();
33                 Signup s = (Signup) hs.getAttribute(SIGNUP_PROCESS);
34                 if (s == null) {
35                         s = new Signup();
36                         hs.setAttribute(SIGNUP_PROCESS, s);
37                 }
38                 return s;
39
40         }
41
42         @Override
43         public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
44                 Signup s = getForm(req);
45                 if (s.submit(resp.getWriter(), req)) {
46                         HttpSession hs = req.getSession();
47                         hs.setAttribute(SIGNUP_PROCESS, null);
48                         resp.getWriter().println(
49                                 translate(req, "Your information has been submitted"
50                                         + " into our system. You will now be sent an email with a web link,"
51                                         + " you need to open that link in your web browser within 24 hours"
52                                         + " or your information will be removed from our system!"));
53                         return;
54                 }
55
56                 super.doPost(req, resp);
57         }
58
59         @Override
60         public boolean needsLogin() {
61                 return false;
62         }
63 }