Merge pull request #3553 from benjiwheeler/join-flow-username-symbols

if username has spaces, provide validation message specifically mentioning that
This commit is contained in:
Benjamin Wheeler 2019-11-20 08:09:27 -05:00 committed by GitHub
commit 9e78443427
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 1 deletions

View file

@ -230,6 +230,7 @@
"registration.validationUsernameNotAllowed": "Username not allowed",
"registration.validationUsernameVulgar": "Hmm, that looks inappropriate",
"registration.validationUsernameInvalid": "Invalid username",
"registration.validationUsernameSpaces": "Usernames can't have spaces",
"registration.validationEmailInvalid": "Email doesnt look right. Try another?",
"registration.waitForApproval": "Wait for Approval",
"registration.waitForApprovalDescription": "You can log into your Scratch Account now, but the features specific to Teachers are not yet available. Your information is being reviewed. Please be patient, the approval process can take up to one day. You will receive an email indicating your account has been upgraded once your account has been approved.",

View file

@ -9,6 +9,8 @@ module.exports.validateUsernameLocally = username => {
return {valid: false, errMsgId: 'registration.validationUsernameMinLength'};
} else if (username.length > 20) {
return {valid: false, errMsgId: 'registration.validationUsernameMaxLength'};
} else if (/\s/i.test(username)) {
return {valid: false, errMsgId: 'registration.validationUsernameSpaces'};
} else if (!/^[\w-]+$/i.test(username)) {
return {valid: false, errMsgId: 'registration.validationUsernameRegexp'};
}

View file

@ -33,7 +33,7 @@ describe('unit test lib/validate.js', () => {
test('validate username spaces not allowed', () => {
const response = validate.validateUsernameLocally('abc def');
expect(response).toEqual({valid: false, errMsgId: 'registration.validationUsernameRegexp'});
expect(response).toEqual({valid: false, errMsgId: 'registration.validationUsernameSpaces'});
});
test('validate username special chars not allowed', () => {