X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Fpages%2Faccount%2FChangeForm.java;h=086c8a85c503aa350917eb5780f6780d484cee57;hp=667dc751fbc84a9e28637e410ba728e4e922a4b8;hb=d7271af56f7c4f3381ea079f1be1a52124e1d241;hpb=25f59f370978c0e9789821a15d89a83d5d702622 diff --git a/src/org/cacert/gigi/pages/account/ChangeForm.java b/src/org/cacert/gigi/pages/account/ChangeForm.java index 667dc751..086c8a85 100644 --- a/src/org/cacert/gigi/pages/account/ChangeForm.java +++ b/src/org/cacert/gigi/pages/account/ChangeForm.java @@ -10,7 +10,7 @@ import org.cacert.gigi.dbObjects.User; import org.cacert.gigi.localisation.Language; 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 { @@ -29,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); @@ -48,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.")); } }