);
-export default CreateDisplayNameDialog;
+export default CreateUsernameDialog;
diff --git a/client/coral-sign-in/containers/ChangeDisplayNameContainer.js b/client/coral-sign-in/containers/ChangeUsernameContainer.js
similarity index 74%
rename from client/coral-sign-in/containers/ChangeDisplayNameContainer.js
rename to client/coral-sign-in/containers/ChangeUsernameContainer.js
index 625985b63..33ae63614 100644
--- a/client/coral-sign-in/containers/ChangeDisplayNameContainer.js
+++ b/client/coral-sign-in/containers/ChangeUsernameContainer.js
@@ -4,21 +4,21 @@ import {connect} from 'react-redux';
import validate from 'coral-framework/helpers/validate';
import errorMsj from 'coral-framework/helpers/error';
-import CreateDisplayNameDialog from '../components/CreateDisplayNameDialog';
+import CreateUsernameDialog from '../components/CreateUsernameDialog';
import I18n from 'coral-framework/modules/i18n/i18n';
import translations from '../translations';
const lang = new I18n(translations);
import {
- showCreateDisplayNameDialog,
- hideCreateDisplayNameDialog,
+ showCreateUsernameDialog,
+ hideCreateUsernameDialog,
invalidForm,
validForm,
- createDisplayName
+ createUsername
} from '../../coral-framework/actions/auth';
-class ChangeDisplayNameContainer extends Component {
+class ChangeUsernameContainer extends Component {
initialState = {
formData: {
username: '',
@@ -31,7 +31,7 @@ class ChangeDisplayNameContainer extends Component {
super(props);
this.state = this.initialState;
this.handleChange = this.handleChange.bind(this);
- this.handleSubmitDisplayName = this.handleSubmitDisplayName.bind(this);
+ this.handleSubmitUsername = this.handleSubmitUsername.bind(this);
this.handleClose = this.handleClose.bind(this);
this.addError = this.addError.bind(this);
}
@@ -81,13 +81,13 @@ class ChangeDisplayNameContainer extends Component {
this.setState({showErrors: show});
}
- handleSubmitDisplayName(e) {
+ handleSubmitUsername(e) {
e.preventDefault();
const {errors} = this.state;
const {validForm, invalidForm} = this.props;
this.displayErrors();
if (this.isCompleted() && !Object.keys(errors).length) {
- this.props.createDisplayName(this.props.user.id, this.state.formData);
+ this.props.createUsername(this.props.user.id, this.state.formData);
validForm();
} else {
invalidForm(lang.t('createdisplay.checkTheForm'));
@@ -95,19 +95,19 @@ class ChangeDisplayNameContainer extends Component {
}
handleClose() {
- this.props.hideCreateDisplayNameDialog();
+ this.props.hideCreateUsernameDialog();
}
render() {
const {loggedIn, auth, offset} = this.props;
return (
- ({
});
const mapDispatchToProps = dispatch => ({
- createDisplayName: (userid, formData) => dispatch(createDisplayName(userid, formData)),
- showCreateDisplayNameDialog: () => dispatch(showCreateDisplayNameDialog()),
- hideCreateDisplayNameDialog: () => dispatch(hideCreateDisplayNameDialog()),
+ createUsername: (userid, formData) => dispatch(createUsername(userid, formData)),
+ showCreateUsernameDialog: () => dispatch(showCreateUsernameDialog()),
+ hideCreateUsernameDialog: () => dispatch(hideCreateUsernameDialog()),
invalidForm: error => dispatch(invalidForm(error)),
validForm: () => dispatch(validForm())
});
@@ -132,4 +132,4 @@ const mapDispatchToProps = dispatch => ({
export default connect(
mapStateToProps,
mapDispatchToProps
-)(ChangeDisplayNameContainer);
+)(ChangeUsernameContainer);
diff --git a/errors.js b/errors.js
index ee68b67fd..9bfa200da 100644
--- a/errors.js
+++ b/errors.js
@@ -141,6 +141,12 @@ const ErrInstallLock = new APIError('install lock active', {
status: 500
});
+// ErrPermissionUpdateUsername is returned when the user does not have permission to update their username.
+const ErrPermissionUpdateUsername = new APIError('You do not have permission to update your username.', {
+ translation_key: 'EDIT_USERNAME_NOT_AUTHORIZED',
+ status: 500
+});
+
module.exports = {
ExtendableError,
APIError,
@@ -159,6 +165,7 @@ module.exports = {
ErrInvalidAssetURL,
ErrAuthentication,
ErrNotAuthorized,
+ ErrPermissionUpdateUsername,
ErrSettingsInit,
ErrInstallLock
};
diff --git a/services/setup.js b/services/setup.js
index 2bfbc66a0..1f1542d5e 100644
--- a/services/setup.js
+++ b/services/setup.js
@@ -57,7 +57,7 @@ module.exports = class SetupService {
// Verify other properties of the user.
return Promise.all([
- UsersService.isValidDisplayName(username, false),
+ UsersService.isValidUsername(username, false),
UsersService.isValidPassword(password),
settingsModel.validate()
]);
diff --git a/services/users.js b/services/users.js
index f715fa9f4..aef30aa75 100644
--- a/services/users.js
+++ b/services/users.js
@@ -176,7 +176,7 @@ module.exports = class UsersService {
* @param {Boolean} checkAgainstWordlist enables cheching against the wordlist
* @return {Promise}
*/
- static isValidUserName(username, checkAgainstWordlist = true) {
+ static isValidUsername(username, checkAgainstWordlist = true) {
const onlyLettersNumbersUnderscore = /^[A-Za-z0-9_]+$/;
if (!username) {
@@ -230,7 +230,7 @@ module.exports = class UsersService {
username = username.trim();
return Promise.all([
- UsersService.isValidUserName(username),
+ UsersService.isValidUsername(username),
UsersService.isValidPassword(password)
])
.then(() => { // username is valid
@@ -688,7 +688,7 @@ module.exports = class UsersService {
}
}).then((result) => {
return result.nModified > 0 ? result :
- Promise.reject(new Error('You do not have permission to update your username.'));
+ Promise.reject(errors.ErrPermissionUpdateUsername);
});
}
};
diff --git a/test/e2e/pages/embedStreamPage.js b/test/e2e/pages/embedStreamPage.js
index b25eec419..ca72df1db 100644
--- a/test/e2e/pages/embedStreamPage.js
+++ b/test/e2e/pages/embedStreamPage.js
@@ -19,7 +19,7 @@ const embedStreamCommands = {
.setValue('@signInDialogEmail', user.email)
.setValue('@signInDialogPassword', user.pass)
.setValue('@signUpDialogConfirmPassword', user.pass)
- .setValue('@signUpDialogDisplayName', user.username)
+ .setValue('@signUpDialogUsername', user.username)
.waitForElementVisible('@signUpButton')
.click('@signUpButton')
.waitForElementVisible('@signInViewTrigger')
@@ -95,7 +95,7 @@ module.exports = {
signUpDialogConfirmPassword: {
selector: '#signInDialog #confirmPassword'
},
- signUpDialogDisplayName: {
+ signUpDialogUsername: {
selector: '#signInDialog #username'
},
logInButton: {