X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Fpages%2Fwot%2FAssurePage.java;h=c29b2388cd83a13e7cabd63fe9b6142b08df0603;hp=94c582f220e5765f19c3d2d2d7d05d8182646d9c;hb=17a15662212d973d12ed4cea3f5eaa9c0d1169ed;hpb=aa5723dbb64ec8efa63909d39ff72364f0a5ee96 diff --git a/src/org/cacert/gigi/pages/wot/AssurePage.java b/src/org/cacert/gigi/pages/wot/AssurePage.java index 94c582f2..c29b2388 100644 --- a/src/org/cacert/gigi/pages/wot/AssurePage.java +++ b/src/org/cacert/gigi/pages/wot/AssurePage.java @@ -2,8 +2,6 @@ package org.cacert.gigi.pages.wot; import java.io.IOException; import java.io.PrintWriter; -import java.sql.Date; -import java.util.Calendar; import java.util.HashMap; import javax.servlet.http.HttpServletRequest; @@ -16,10 +14,9 @@ import org.cacert.gigi.dbObjects.User; import org.cacert.gigi.output.DateSelector; import org.cacert.gigi.output.template.Form; import org.cacert.gigi.output.template.Template; -import org.cacert.gigi.pages.LoginPage; import org.cacert.gigi.pages.Page; import org.cacert.gigi.util.AuthorizationContext; -import org.cacert.gigi.util.Notary; +import org.cacert.gigi.util.HTMLEncoder; public class AssurePage extends Page { @@ -27,11 +24,10 @@ public class AssurePage extends Page { DateSelector ds = new DateSelector("day", "month", "year"); - Template t; + private static final Template t = new Template(AssuranceForm.class.getResource("AssureeSearch.templ")); public AssurePage() { - super("Assure someone"); - t = new Template(AssuranceForm.class.getResource("AssureeSearch.templ")); + super("Verify someone"); } @@ -54,25 +50,21 @@ public class AssurePage extends Page { PrintWriter out = resp.getWriter(); if (req.getParameter("search") == null) { AssuranceForm form = Form.getForm(req, AssuranceForm.class); - if (form.submit(out, req)) { - out.println(translate(req, "Assurance complete.")); - } else { - try { - Notary.checkAssuranceIsPossible(LoginPage.getUser(req), form.getAssuree()); - form.output(out, getLanguage(req), new HashMap()); - } catch (GigiApiException e) { - e.format(out, Page.getLanguage(req)); + if (form.submitProtected(out, req)) { + if (form.isWithPasswordReset()) { + resp.getWriter().println(HTMLEncoder.encodeHTML(translate(req, "Password reset successful."))); } + out.println(translate(req, "Verification complete.")); + return; } - return; } try (GigiPreparedStatement ps = new GigiPreparedStatement("SELECT `users`.`id`, `verified` FROM `users` INNER JOIN `certOwners` ON `certOwners`.`id`=`users`.`id` WHERE `email`=? AND `dob`=? AND `deleted` IS NULL")) { + ds.update(req); + ps.setString(1, req.getParameter("email")); - Calendar c = Calendar.getInstance(); - c.set(Integer.parseInt(req.getParameter("year")), Integer.parseInt(req.getParameter("month")) - 1, Integer.parseInt(req.getParameter("day"))); - ps.setDate(2, new Date(c.getTimeInMillis())); + ps.setDate(2, ds.getDate().toSQLDate()); GigiResultSet rs = ps.executeQuery(); int id = 0; if (rs.next()) { @@ -87,9 +79,7 @@ public class AssurePage extends Page { } else { User assuree = User.getById(id); - User myself = LoginPage.getUser(req); try { - Notary.checkAssuranceIsPossible(myself, assuree); new AssuranceForm(req, assuree).output(out, getLanguage(req), new HashMap()); } catch (GigiApiException e) { e.format(out, Page.getLanguage(req)); @@ -97,12 +87,12 @@ public class AssurePage extends Page { } } } else { - out.print("
"); - - out.println(translate(req, "I'm sorry, there was no email and date of birth matching" + " what you entered in the system. Please double check" + " your information.")); - out.print("
"); + throw new GigiApiException("I'm sorry, there was no email and date of birth matching" // + + " what you entered in the system. Please double check your information."); } + } catch (GigiApiException e) { + e.format(out, getLanguage(req)); } } }