X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Fpages%2Faccount%2FChangeForm.java;h=086c8a85c503aa350917eb5780f6780d484cee57;hb=65e50396a0c9fdc000036f5990ffa1b388df4c5e;hp=ceaee92e57e3441fbc5a1b34395598c9353e5127;hpb=e409ba881965634f63f0b67824bc93dda4ec4327;p=gigi.git diff --git a/src/org/cacert/gigi/pages/account/ChangeForm.java b/src/org/cacert/gigi/pages/account/ChangeForm.java index ceaee92e..086c8a85 100644 --- a/src/org/cacert/gigi/pages/account/ChangeForm.java +++ b/src/org/cacert/gigi/pages/account/ChangeForm.java @@ -8,9 +8,9 @@ import javax.servlet.http.HttpServletRequest; import org.cacert.gigi.GigiApiException; import org.cacert.gigi.dbObjects.User; import org.cacert.gigi.localisation.Language; -import org.cacert.gigi.output.Form; +import org.cacert.gigi.output.template.Form; import org.cacert.gigi.output.template.Template; -import org.cacert.gigi.pages.Page; +import org.cacert.gigi.output.template.TranslateCommand; public class ChangeForm extends Form { @@ -21,10 +21,7 @@ public class ChangeForm extends Form { this.target = target; } - private static Template t; - static { - t = new Template(ChangePasswordPage.class.getResource("ChangePasswordForm.templ")); - } + private static final Template t = new Template(ChangePasswordPage.class.getResource("ChangePasswordForm.templ")); @Override public void outputContent(PrintWriter out, Language l, Map vars) { @@ -32,18 +29,16 @@ public class ChangeForm extends Form { } @Override - public boolean submit(PrintWriter out, HttpServletRequest req) { + public SubmissionResult submit(HttpServletRequest req) throws GigiApiException { 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; + throw new GigiApiException("All fields are required."); } if ( !p1.equals(p2)) { - new GigiApiException("New passwords do not match.").format(out, Page.getLanguage(req)); - return false; + throw new GigiApiException("New passwords do not match."); } try { target.changePassword(oldpassword, p1); @@ -51,10 +46,9 @@ public class ChangeForm extends Form { error.mergeInto(e); } if ( !error.isEmpty()) { - error.format(out, Page.getLanguage(req)); - return false; + throw error; } - return true; + return new SuccessMessageResult(new TranslateCommand("Password changed.")); } }