]> WPIA git - gigi.git/commitdiff
add: Check the primary email address to be valid before creating an User
authorBenny Baumann <BenBE1987@gmx.net>
Sun, 19 Mar 2017 17:10:48 +0000 (18:10 +0100)
committerBenny Baumann <BenBE1987@gmx.net>
Sun, 19 Mar 2017 17:10:48 +0000 (18:10 +0100)
Change-Id: Icdf298892b7b64d72c310bdb633c8e05113d6eda

src/club/wpia/gigi/dbObjects/User.java

index 9703fa8f55722956bd01293cbe51b290ac813d77..a4c32014c3209132f1863733bd9e8b22a14997a9 100644 (file)
@@ -17,6 +17,7 @@ import club.wpia.gigi.database.GigiResultSet;
 import club.wpia.gigi.dbObjects.CATS.CATSType;
 import club.wpia.gigi.dbObjects.Country.CountryCodeType;
 import club.wpia.gigi.dbObjects.Verification.VerificationType;
+import club.wpia.gigi.email.EmailProvider;
 import club.wpia.gigi.localisation.Language;
 import club.wpia.gigi.output.DateSelector;
 import club.wpia.gigi.pages.PasswordResetPage;
@@ -104,6 +105,11 @@ 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.");
+        }
+
         this.email = email;
         this.dob = dob;
         this.locale = locale;
@@ -118,6 +124,7 @@ public class User extends CertificateOwner {
             query.setString(7, residenceCountry == null ? null : residenceCountry.getCode());
             query.execute();
         }
+
         new EmailAddress(this, email, locale);
     }