]> WPIA git - gigi.git/blobdiff - src/club/wpia/gigi/dbObjects/User.java
fix: ensure that Users and Organisations only are inserted completely
[gigi.git] / src / club / wpia / gigi / dbObjects / User.java
index cdd00d6f3533b2ba7656203a960f4014aad426d7..3c2cd6b03f284d9b8ed71c14a14c59dc3a8400dd 100644 (file)
@@ -105,10 +105,7 @@ public class User extends CertificateOwner {
     }
 
     public User(String email, String password, DayDate dob, Locale locale, Country residenceCountry, NamePart... preferred) throws GigiApiException {
-        // Avoid storing information that obviously won't get through
-        if ( !EmailProvider.isValidMailAddress(email)) {
-            throw new IllegalArgumentException("Invalid email.");
-        }
+        super(validate(email));
 
         this.email = email;
         this.dob = dob;
@@ -128,6 +125,14 @@ public class User extends CertificateOwner {
         new EmailAddress(this, email, locale);
     }
 
+    private static Void validate(String email) {
+        // Avoid storing information that obviously won't get through
+        if ( !EmailProvider.isValidMailAddress(email)) {
+            throw new IllegalArgumentException("Invalid email.");
+        }
+        return null;
+    }
+
     public Name[] getNames() {
         try (GigiPreparedStatement gps = new GigiPreparedStatement("SELECT `id` FROM `names` WHERE `uid`=? AND `deleted` IS NULL", true)) {
             gps.setInt(1, getId());