]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/pages/account/ChangeForm.java
upd: use a more strict pattern for handling forms
[gigi.git] / src / org / cacert / gigi / pages / account / ChangeForm.java
index 667dc751fbc84a9e28637e410ba728e4e922a4b8..582fea07428f47d41ce68af5a2a985c81c2d0bbc 100644 (file)
@@ -10,7 +10,6 @@ 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.localisation.Language;
 import org.cacert.gigi.output.template.Form;
 import org.cacert.gigi.output.template.Template;
-import org.cacert.gigi.pages.Page;
 
 public class ChangeForm extends Form {
 
 
 public class ChangeForm extends Form {
 
@@ -29,18 +28,16 @@ public class ChangeForm extends Form {
     }
 
     @Override
     }
 
     @Override
-    public boolean submit(PrintWriter out, HttpServletRequest req) {
+    public boolean 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) {
         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)) {
         }
         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);
         }
         try {
             target.changePassword(oldpassword, p1);
@@ -48,8 +45,7 @@ public class ChangeForm extends Form {
             error.mergeInto(e);
         }
         if ( !error.isEmpty()) {
             error.mergeInto(e);
         }
         if ( !error.isEmpty()) {
-            error.format(out, Page.getLanguage(req));
-            return false;
+            throw error;
         }
         return true;
     }
         }
         return true;
     }