Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(UserRegistration): Allow spaces and - in first and last name #192

Merged
merged 3 commits into from
Dec 2, 2022

Conversation

ccwemett
Copy link
Contributor

@ccwemett ccwemett commented Nov 21, 2022

Changes

  • Validator allows characters A-Z, a-z, spaces, and dashes within user's first and last name
  • Student username generation removes spaces and dashes from the first name
  • Teacher username generation removes spaces and dashes from first and last name

Test

  • Validator correctly checks the first and last name
  • Username generation appropriately removes any dashes or spaces within the first and last name

Closes #183

Copy link
Member

@geoffreykwan geoffreykwan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionality works well. I have a minor code refactor suggestion.

@@ -165,7 +165,7 @@ public class TeacherUserDetails extends PersistentUserDetails implements Mutable
private String howDidYouHearAboutUs;

public String getCoreUsername() {
return firstname + lastname;
return firstname.replaceAll("[\\s-]+", "") + lastname.replaceAll("[\\s-]+", "");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can change this to just call replaceAll once.

return (firstname + lastname).replaceAll("[\\s-]+", "");

@ccwemett ccwemett changed the title fix(UserRegistration): Allow spaces and - in first and last name #183 fix(UserRegistration): Allow spaces and - in first and last name Nov 30, 2022
@ccwemett ccwemett self-assigned this Nov 30, 2022
#183
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch issue-183-update-account-validation
# Your branch is up to date with 'origin/issue-183-update-account-validation'.
#
# Changes to be committed:
#	modified:   src/main/java/org/wise/portal/domain/authentication/impl/TeacherUserDetails.java
#
Copy link
Member

@geoffreykwan geoffreykwan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Copy link
Member

@geoffreykwan geoffreykwan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@geoffreykwan geoffreykwan merged commit 51ce8df into develop Dec 2, 2022
@geoffreykwan geoffreykwan deleted the issue-183-update-account-validation branch December 2, 2022 21:54
breity added a commit to I-Sparkle-Germany/I-Sparkle-API that referenced this pull request Dec 4, 2022
fix(UserRegistration): Allow spaces and - in first and last name (WISE-Community#192)
@geoffreykwan
Copy link
Member

🎉 This PR is included in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Allow first name and last name to contain space and dash
2 participants