X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Fpages%2Faccount%2FChangeForm.java;h=c678cf1f14032cf5c5d6e52694bcb9278c440d7f;hp=5458b63d9f5ef9d94a9db148cccee44634194410;hb=943d8e7ed0ea5a9d56e7e694a3cbd849c52bad16;hpb=05e8bb67c3407cbecbb528db16b1608d8534907e diff --git a/src/org/cacert/gigi/pages/account/ChangeForm.java b/src/org/cacert/gigi/pages/account/ChangeForm.java index 5458b63d..c678cf1f 100644 --- a/src/org/cacert/gigi/pages/account/ChangeForm.java +++ b/src/org/cacert/gigi/pages/account/ChangeForm.java @@ -13,47 +13,48 @@ import org.cacert.gigi.output.template.Template; import org.cacert.gigi.pages.Page; public class ChangeForm extends Form { - User target; - - public ChangeForm(HttpServletRequest hsr, User target) { - super(hsr); - this.target = target; - } - - private static Template t; - static { - t = new Template(ChangePasswordPage.class.getResource("ChangePasswordForm.templ")); - } - - @Override - public void outputContent(PrintWriter out, Language l, Map vars) { - t.output(out, l, vars); - } - - @Override - public boolean submit(PrintWriter out, HttpServletRequest req) { - String oldpassword = req.getParameter("oldpassword"); - String p1 = req.getParameter("pword1"); - String p2 = req.getParameter("pword2"); - GigiApiException error = new GigiApiException(); - if (oldpassword == null || p1 == null || p2 == null) { - new GigiApiException("All fields are required.").format(out, Page.getLanguage(req)); - return false; - } - if (!p1.equals(p2)) { - new GigiApiException("New passwords do not match.").format(out, Page.getLanguage(req)); - return false; - } - try { - target.changePassword(oldpassword, p1); - } catch (GigiApiException e) { - error.mergeInto(e); - } - if (!error.isEmpty()) { - error.format(out, Page.getLanguage(req)); - return false; - } - return true; - } + + User target; + + public ChangeForm(HttpServletRequest hsr, User target) { + super(hsr); + this.target = target; + } + + private static Template t; + static { + t = new Template(ChangePasswordPage.class.getResource("ChangePasswordForm.templ")); + } + + @Override + public void outputContent(PrintWriter out, Language l, Map vars) { + t.output(out, l, vars); + } + + @Override + public boolean submit(PrintWriter out, HttpServletRequest req) { + String oldpassword = req.getParameter("oldpassword"); + String p1 = req.getParameter("pword1"); + String p2 = req.getParameter("pword2"); + GigiApiException error = new GigiApiException(); + if (oldpassword == null || p1 == null || p2 == null) { + new GigiApiException("All fields are required.").format(out, Page.getLanguage(req)); + return false; + } + if ( !p1.equals(p2)) { + new GigiApiException("New passwords do not match.").format(out, Page.getLanguage(req)); + return false; + } + try { + target.changePassword(oldpassword, p1); + } catch (GigiApiException e) { + error.mergeInto(e); + } + if ( !error.isEmpty()) { + error.format(out, Page.getLanguage(req)); + return false; + } + return true; + } }