);
-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/client/coral-sign-in/translations.js b/client/coral-sign-in/translations.js
index 36ce3fce4..a2bb60819 100644
--- a/client/coral-sign-in/translations.js
+++ b/client/coral-sign-in/translations.js
@@ -26,7 +26,7 @@ export default {
emailORusernameInUse: 'Email address or Username already in use',
requiredField: 'This field is required',
passwordsDontMatch: 'Passwords don\'t match.',
- specialCharacters: 'Display names can contain letters, numbers and _ only',
+ specialCharacters: 'Usernames can contain letters, numbers and _ only',
checkTheForm: 'Invalid Form. Please, check the fields'
},
'createdisplay': {
@@ -37,8 +37,8 @@ export default {
requiredField: 'Required field',
errorCreate: 'Error when changing username',
checkTheForm: 'Invalid Form. Please, check the fields',
- specialCharacters: 'Display names can contain letters, numbers and _ only'
- },
+ specialCharacters: 'Usernames can contain letters, numbers and _ only'
+ }
},
es: {
'signIn': {
diff --git a/errors.js b/errors.js
index ee68b67fd..0c473d59c 100644
--- a/errors.js
+++ b/errors.js
@@ -54,8 +54,8 @@ const ErrEmailTaken = new APIError('Email address already in use', {
status: 400
});
-const ErrDisplayTaken = new APIError('Username already in use', {
- translation_key: 'DISPLAYNAME_IN_USE',
+const ErrUsernameTaken = new APIError('Username already in use', {
+ translation_key: 'USERNAME_IN_USE',
status: 400
});
@@ -64,8 +64,8 @@ const ErrSpecialChars = new APIError('No special characters are allowed in a use
status: 400
});
-const ErrMissingDisplay = new APIError('A username is required to create a user', {
- translation_key: 'DISPLAY_NAME_REQUIRED',
+const ErrMissingUsername = new APIError('A username is required to create a user', {
+ translation_key: 'USERNAME_REQUIRED',
status: 400
});
@@ -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,
@@ -151,14 +157,15 @@ module.exports = {
ErrMissingToken,
ErrEmailTaken,
ErrSpecialChars,
- ErrMissingDisplay,
+ ErrMissingUsername,
ErrContainsProfanity,
- ErrDisplayTaken,
+ ErrUsernameTaken,
ErrAssetCommentingClosed,
ErrNotFound,
ErrInvalidAssetURL,
ErrAuthentication,
ErrNotAuthorized,
+ ErrPermissionUpdateUsername,
ErrSettingsInit,
ErrInstallLock
};
diff --git a/routes/api/account/index.js b/routes/api/account/index.js
index 3de9d41c3..4eab8b920 100644
--- a/routes/api/account/index.js
+++ b/routes/api/account/index.js
@@ -123,7 +123,7 @@ router.put('/username', authorization.needed(), (req, res, next) => {
})
.catch(error => {
if (error.code === 11000) {
- next(errors.ErrDisplayTaken);
+ next(errors.ErrUsernameTaken);
} else {
next(error);
}
diff --git a/services/passport.js b/services/passport.js
index 0560e54bc..229541521 100644
--- a/services/passport.js
+++ b/services/passport.js
@@ -103,9 +103,7 @@ if (process.env.TALK_FACEBOOK_APP_ID && process.env.TALK_FACEBOOK_APP_SECRET &&
clientSecret: process.env.TALK_FACEBOOK_APP_SECRET,
callbackURL: `${process.env.TALK_ROOT_URL}/api/v1/auth/facebook/callback`,
- // TODO: remove username reference when we have steps in the FE to handle
- // the username create flow.
- profileFields: ['id', 'username', 'picture.type(large)']
+ profileFields: ['id', 'displayName', 'picture.type(large)']
}, (accessToken, refreshToken, profile, done) => {
UsersService
.findOrCreateExternalUser(profile)
diff --git a/services/users.js b/services/users.js
index 13858f575..b09a7d399 100644
--- a/services/users.js
+++ b/services/users.js
@@ -109,7 +109,7 @@ module.exports = class UsersService {
* @param {Object} profile - User social/external profile
* @param {Function} done [description]
*/
- static findOrCreateExternalUser({id, provider, displayname}) {
+ static findOrCreateExternalUser({id, provider, displayName}) {
return UserModel
.findOne({
profiles: {
@@ -124,7 +124,7 @@ module.exports = class UsersService {
return user;
}
- let username = UsersService.castUsername(displayname);
+ let username = UsersService.castUsername(displayName);
// The user was not found, lets create them!
user = new UserModel({
@@ -180,7 +180,7 @@ module.exports = class UsersService {
const onlyLettersNumbersUnderscore = /^[A-Za-z0-9_]+$/;
if (!username) {
- return Promise.reject(errors.ErrMissingDisplay);
+ return Promise.reject(errors.ErrMissingUsername);
}
if (!onlyLettersNumbersUnderscore.test(username)) {
@@ -257,7 +257,7 @@ module.exports = class UsersService {
if (err) {
if (err.code === 11000) {
if (err.message.match('Username')) {
- return reject(errors.ErrDisplayTaken);
+ return reject(errors.ErrUsernameTaken);
}
return reject(errors.ErrEmailTaken);
}
@@ -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: {