Skip to content

Commit

Permalink
Merge pull request #2 from WISE-Community/develop
Browse files Browse the repository at this point in the history
fix(UserRegistration): Allow spaces and - in first and last name (WISE-Community#192)
  • Loading branch information
breity authored Dec 4, 2022
2 parents 6a0ec13 + 51ce8df commit 439bcc0
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@
</natures>
<filteredResources>
<filter>
<id>1598983010649</id>
<id>1666988752460</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ protected HashMap<String, Object> convertUserToMap(User user) {
}

protected Boolean isNameValid(String name) {
Pattern p = Pattern.compile("[a-zA-Z]+");
Pattern p = Pattern.compile("^(?![ -])[a-zA-Z -]+(?<![ -])$");
Matcher m = p.matcher(name);
return m.matches();
}
Expand Down

0 comments on commit 439bcc0

Please sign in to comment.