1 package club.wpia.gigi.pages.wot;
3 import java.io.IOException;
6 import javax.servlet.http.HttpServletRequest;
7 import javax.servlet.http.HttpServletResponse;
9 import club.wpia.gigi.dbObjects.User;
10 import club.wpia.gigi.dbObjects.Verification;
11 import club.wpia.gigi.output.template.Form;
12 import club.wpia.gigi.pages.LoginPage;
13 import club.wpia.gigi.pages.Page;
14 import club.wpia.gigi.util.AuthorizationContext;
16 public class RequestTTPPage extends Page {
18 public static final String PATH = "/wot/ttp";
20 public RequestTTPPage() {
25 public boolean beforePost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
26 return Form.getForm(req, RequestTTPForm.class).submitExceptionProtected(req, resp);
30 public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
31 if (Form.printFormErrors(req, resp.getWriter())) {
32 Form.getForm(req, RequestTTPForm.class).output(resp.getWriter(), getLanguage(req), getDefaultVars(req));
37 public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
38 User u = LoginPage.getUser(req);
39 Map<String, Object> map = getDefaultVars(req);
40 if (u.isInGroup(RequestTTPForm.TTP_APPLICANT)) {
41 map.put("inProgress", true);
43 if (u.getVerificationPoints() < 100) {
45 for (Verification a : u.getReceivedVerifications()) {
46 if (a.getMethod().equals(Verification.VerificationType.TTP_ASSISTED.getDescription())) {
52 map.put("form", new RequestTTPForm(req));
54 map.put("nothing", true);
57 map.put("nothing", true);
60 map.put("form", new RequestTTPForm(req));
61 getDefaultTemplate().output(resp.getWriter(), getLanguage(req), map);
65 public boolean isPermitted(AuthorizationContext ac) {
66 return ac != null && ac.getTarget() instanceof User;