]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/pages/admin/support/SupportUserDetailsForm.java
fix: support: no primary email address in list of secondary addresses
[gigi.git] / src / org / cacert / gigi / pages / admin / support / SupportUserDetailsForm.java
index 737a94c116b7c99fda767144fbc54d71ee2055d6..b49eaad9154413977e153145d4e1fcc6e131e563 100644 (file)
@@ -21,6 +21,8 @@ public class SupportUserDetailsForm extends Form {
 
     private SupportedUser user;
 
+    private DateSelector dobSelector;
+
     static {
         t = new Template(FindDomainForm.class.getResource("SupportUserDetailsForm.templ"));
     }
@@ -28,12 +30,30 @@ public class SupportUserDetailsForm extends Form {
     public SupportUserDetailsForm(HttpServletRequest hsr, SupportedUser user) {
         super(hsr);
         this.user = user;
+        dobSelector = new DateSelector("dobd", "dobm", "doby", user.getTargetUser().getDoB());
     }
 
     @Override
     public boolean submit(PrintWriter out, HttpServletRequest req) throws GigiApiException {
-
-        return false;
+        if (user.getTicket() == null) {
+            return false;
+        }
+        dobSelector.update(req);
+        String fname = req.getParameter("fname");
+        String mname = req.getParameter("mname");
+        String lname = req.getParameter("lname");
+        String suffix = req.getParameter("suffix");
+        if (fname == null || mname == null || lname == null | suffix == null) {
+            throw new GigiApiException("Incomplete request!");
+        }
+        if ( !dobSelector.isValid()) {
+            throw new GigiApiException("Invalid date of birth!");
+        }
+        Name newName = new Name(fname, lname, mname, suffix);
+        if (user.setDob(dobSelector.getDate()) | user.setName(newName)) {
+            user.submitSupportAction();
+        }
+        return true;
     }
 
     @Override
@@ -46,7 +66,7 @@ public class SupportUserDetailsForm extends Form {
         vars.put("lname", name.getLname());
         vars.put("suffix", name.getSuffix());
         vars.put("assurer", user.canAssure());
-        vars.put("dob", new DateSelector("dobd", "dobm", "doby", user.getDoB()));
+        vars.put("dob", dobSelector);
         vars.put("blockedassurer", user.isInGroup(Group.BLOCKEDASSURER));
         vars.put("codesign", user.isInGroup(Group.CODESIGNING));
         vars.put("orgassurer", user.isInGroup(Group.ORGASSURER));