Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding some extra validation for input fields in the login and edit display name pages so that empty or whitespace names are no longer allowed. This should fix the #1565 issue. It also changes all instances of the display name to the user's auth ID in the website only in case it doesn't match the validation. I added a small file with the function that's used to validate these display names in `website/src/lib/display_name_validation.ts`. --------- Co-authored-by: notmd <tinhmeo10@gmail.com>
- Loading branch information
1 parent
e38d639
commit ed0e3cb
Showing
8 changed files
with
92 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export const validDisplayNameRegex = /^\S+/g; | ||
/** | ||
* Given a user's display name and its ID, returns a valid display name, | ||
* checking if the original display name is invalid (e.g. empty or starts | ||
* with whitespace). | ||
* | ||
* @param {string} displayName The user's display name. | ||
* @param {string} id The user's ID. | ||
* @returns {string} A valid display name. | ||
*/ | ||
export const getValidDisplayName = (displayName: string, id: string): string => { | ||
return !isValidDisplayName(displayName) ? id : displayName; | ||
}; | ||
|
||
export const isValidDisplayName = (displayName: string) => { | ||
return displayName && displayName.match(validDisplayNameRegex); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters