suggest username when taken on register#32
Open
caoerz-helen wants to merge 1 commit into
Open
Conversation
Pull Request Test Coverage Report for Build 21601855893Details
💛 - Coveralls |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Resolves #1
Summary
When a user enters a username that is already taken on the register page, the UI now suggests an alternative username (e.g.,
test1→test11) instead of only showing “Username taken”.Changes
Added two helper functions in
public/src/client/register.js:async function isUsernameAvailable(name)Promise.allSettledwithapi.head('/users/bySlug/:slug')andapi.head('/groups/:name')to check whether a username or group already exists.async function suggestedUsername(baseSlug)baseSlug + 1..20and returns the first candidate whereisUsernameAvailablereturnstrue.Updated
validateUsername(username, callback)to:isUsernameAvailable.showSuccessas before.suggestedUsername(userslug).[[error:username-taken]][[user:username-taken-workaround, <suggestion>]]validationError = true.[[error:username-taken]]message.callback()is still called once validation finishes.Kept the new text English-only by explicitly using
config.defaultLangfor the workaround message, as required.How I Tested
Case 1 – Username already taken
test1first.test1into the Username field and blurred the input.Case 2 – Username available
unique123).Case 3 – Existing validation behavior
utils.isUserNameValidScreenshots
Register page showing taken username

test1and suggestion message