fix: check if email is a valid pattern while account creation
authorINOPIAE <m.maengel@inopiae.de>
Mon, 29 Jun 2020 08:27:05 +0000 (10:27 +0200)
committerINOPIAE <m.maengel@inopiae.de>
Wed, 8 Jul 2020 03:51:43 +0000 (05:51 +0200)
Change-Id: Ic859ea7cb02fcaebe7e26d9b141fd7d97e9c1122

src/club/wpia/gigi/pages/main/Signup.java
tests/club/wpia/gigi/pages/main/RegisterPageTest.java

index 60d85be..1c7942b 100644 (file)
@@ -141,6 +141,11 @@ public class Signup extends Form {
             throw gaPassword;
         }
         GigiApiException ga2 = new GigiApiException();
+
+        if ( !EmailProvider.isValidMailAddress(email)) {
+            ga2.mergeInto(new GigiApiException("This email address seems not to be valid."));
+        }
+
         try (GigiPreparedStatement q1 = new GigiPreparedStatement("SELECT * FROM `emails` WHERE `email`=? AND `deleted` IS NULL"); GigiPreparedStatement q2 = new GigiPreparedStatement("SELECT * FROM `certOwners` INNER JOIN `users` ON `users`.`id`=`certOwners`.`id` WHERE `email`=? AND `deleted` IS NULL")) {
             q1.setString(1, email);
             q2.setString(1, email);
index 02404de..7140929 100644 (file)
@@ -82,6 +82,9 @@ public class RegisterPageTest extends ManagedTest {
     @Test
     public void testNoEmail() throws IOException {
         testFailedForm("fname=a&lname=b&pword1=ap&pword2=ap&day=1&month=1&year=1910&tos_agree=1&dp_agree=1");
+        testFailedForm("fname=a&lname=b&email=e&pword1=ap&pword2=ap&day=1&month=1&year=1910&tos_agree=1&dp_agree=1");
+        testFailedForm("fname=a&lname=b&email=e@&pword1=ap&pword2=ap&day=1&month=1&year=1910&tos_agree=1&dp_agree=1");
+        testFailedForm("fname=a&lname=b&email=@d.ef&pword1=ap&pword2=ap&day=1&month=1&year=1910&tos_agree=1&dp_agree=1");
     }
 
     @Test