diff --git a/client/src/components/settings/Username.js b/client/src/components/settings/Username.js
index 678ef22cff..32bacb2760 100644
--- a/client/src/components/settings/Username.js
+++ b/client/src/components/settings/Username.js
@@ -47,11 +47,14 @@ const mapDispatchToProps = dispatch =>
const invalidCharsRE = /[/\s?:@=&"'<>#%{}|\\^~[\]`,.;!*()$]/;
const invlaidCharError = {
valid: false,
- error: 'Username contains invalid characters'
+ error: 'Username contains invalid characters.'
};
const valididationSuccess = { valid: true, error: null };
const usernameTooShort = { valid: false, error: 'Username is too short' };
+const hex = '[0-9a-f]';
+const tempUserRegex = new RegExp(`^fcc${hex}{8}-(${hex}{4}-){3}${hex}{12}$`);
+
class UsernameSettings extends Component {
constructor(props) {
super(props);
@@ -60,7 +63,8 @@ class UsernameSettings extends Component {
isFormPristine: true,
formValue: props.username,
characterValidation: { valid: false, error: null },
- submitClicked: false
+ submitClicked: false,
+ isUserNew: tempUserRegex.test(props.username)
};
this.handleChange = this.handleChange.bind(this);
@@ -77,7 +81,8 @@ class UsernameSettings extends Component {
/* eslint-disable-next-line react/no-did-update-set-state */
return this.setState({
isFormPristine: username === formValue,
- submitClicked: false
+ submitClicked: false,
+ isUserNew: tempUserRegex.test(username)
});
}
return null;
@@ -138,21 +143,31 @@ class UsernameSettings extends Component {
if (!validating && !isValidUsername) {
return (
- Username not available
+ Username not available.
);
}
if (validating) {
return (
- Validating username
+ Validating username...
);
}
- if (!validating && isValidUsername) {
+ if (!validating && isValidUsername && this.state.isUserNew) {
return (
- Username is available
+ Username is available.
+
+ );
+ } else if (!validating && isValidUsername && !this.state.isUserNew) {
+ return (
+
+ Username is available.
+
+ Please note, changing your username will also change the URL to your
+ profile and your certifications.
+
);
}