suggest alternative username when chosen one is taken #89
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
The registration logic responsible for validating usernames is implemented on the client side. To make the change, I located the validateUsername function inside public/src/client/register.js. Since the "username taken" message originates from validateUsername, this was the correct place to modify the behavior to also suggest an alternative username.
Description
This pull request updates the registration form logic in public/src/client/register.js to improve the user experience when a chosen username is already in use.
Previously, the UI only displayed an error message ("Username taken"). Now, if the entered username is taken, the form will also display a suggested alternative username by appending a "suffix" string to the original input (e.g., test123 → test123suffix).
Changes include:
Modified validateUsername():
When API checks detect the username is taken, display an error message with a suggested alternative username
Preserves existing success/error logic
Testing:
Enter a username that is known to be taken
Confirm that the error message displays along with a suggested alternative username
Enter a new, unused username to confirm normal registration behavior is unaffected