From 51ce8df50d7b8581eed30e77ea546b6fb257e554 Mon Sep 17 00:00:00 2001 From: ccwemett <66527287+ccwemett@users.noreply.github.com> Date: Fri, 2 Dec 2022 13:54:13 -0800 Subject: [PATCH] fix(UserRegistration): Allow spaces and - in first and last name (#192) --- .project | 4 ++-- .../portal/domain/authentication/impl/StudentUserDetails.java | 2 +- .../portal/domain/authentication/impl/TeacherUserDetails.java | 2 +- .../presentation/web/controllers/user/UserAPIController.java | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.project b/.project index 850f83f876..bff0d2bfa3 100644 --- a/.project +++ b/.project @@ -47,12 +47,12 @@ - 1598983010649 + 1666988752460 30 org.eclipse.core.resources.regexFilterMatcher - node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ diff --git a/src/main/java/org/wise/portal/domain/authentication/impl/StudentUserDetails.java b/src/main/java/org/wise/portal/domain/authentication/impl/StudentUserDetails.java index 03420a4fa6..f583a8fd90 100644 --- a/src/main/java/org/wise/portal/domain/authentication/impl/StudentUserDetails.java +++ b/src/main/java/org/wise/portal/domain/authentication/impl/StudentUserDetails.java @@ -127,7 +127,7 @@ public class StudentUserDetails extends PersistentUserDetails implements Mutable private String accountAnswer; public String getCoreUsername() { - String firstname = getFirstname(); + String firstname = getFirstname().replaceAll("[\\s-]+", ""); String lastnameInitial = getLastname().substring(0, 1); Calendar birthday = Calendar.getInstance(); diff --git a/src/main/java/org/wise/portal/domain/authentication/impl/TeacherUserDetails.java b/src/main/java/org/wise/portal/domain/authentication/impl/TeacherUserDetails.java index 95d432cad2..76f7e51340 100644 --- a/src/main/java/org/wise/portal/domain/authentication/impl/TeacherUserDetails.java +++ b/src/main/java/org/wise/portal/domain/authentication/impl/TeacherUserDetails.java @@ -165,7 +165,7 @@ public class TeacherUserDetails extends PersistentUserDetails implements Mutable private String howDidYouHearAboutUs; public String getCoreUsername() { - return firstname + lastname; + return (firstname + lastname).replaceAll("[\\s-]+", ""); } public String[] getUsernameSuffixes() { diff --git a/src/main/java/org/wise/portal/presentation/web/controllers/user/UserAPIController.java b/src/main/java/org/wise/portal/presentation/web/controllers/user/UserAPIController.java index d1b3b90072..9db62a5190 100644 --- a/src/main/java/org/wise/portal/presentation/web/controllers/user/UserAPIController.java +++ b/src/main/java/org/wise/portal/presentation/web/controllers/user/UserAPIController.java @@ -325,7 +325,7 @@ protected HashMap convertUserToMap(User user) { } protected Boolean isNameValid(String name) { - Pattern p = Pattern.compile("[a-zA-Z]+"); + Pattern p = Pattern.compile("^(?![ -])[a-zA-Z -]+(?