diff --git a/api-server/common/models/user.js b/api-server/common/models/user.js index 7db7b13e78..7ff1db25c0 100644 --- a/api-server/common/models/user.js +++ b/api-server/common/models/user.js @@ -127,9 +127,6 @@ function nextTick(fn) { const getRandomNumber = () => Math.random(); function populateRequiredFields(user) { - // by default, the displayUsername will have - // the same value as the username - user.displayUsername = user.username; user.username = user.username.trim().toLowerCase(); user.email = typeof user.email === 'string' @@ -350,7 +347,6 @@ export default function(User) { if (!username && (!email || !isEmail(email))) { return Promise.resolve(false); } - username = username.toLowerCase(); log('checking existence'); // check to see if username is on blacklist @@ -399,7 +395,6 @@ export default function(User) { cb(null, {}); }); } - username = username.toLowerCase(); return User.findOne({ where: { username } }, (err, user) => { if (err) { return cb(err); @@ -729,13 +724,13 @@ export default function(User) { User.prototype.updateMyUsername = function updateMyUsername(newUsername) { return Observable.defer(() => { - const isOwnUsername = isTheSame(newUsername.toLowerCase(), this.username); + const isOwnUsername = isTheSame(newUsername, this.username); if (isOwnUsername) { return Observable.of(dedent` ${newUsername} is already associated with this account. `); } - return Observable.fromPromise(User.doesExist(newUsername.toLowerCase())); + return Observable.fromPromise(User.doesExist(newUsername)); }).flatMap(boolOrMessage => { if (typeof boolOrMessage === 'string') { return Observable.of(boolOrMessage); @@ -746,20 +741,14 @@ export default function(User) { `); } - const usernameUpdate = new Promise((resolve, reject) => { - this.updateAttributes( - { - username: newUsername.toLowerCase(), - displayUsername: newUsername - }, - err => { - if (err) { - return reject(err); - } - return resolve(); + const usernameUpdate = new Promise((resolve, reject) => + this.updateAttribute('username', newUsername, err => { + if (err) { + return reject(err); } - ); - }); + return resolve(); + }) + ); return Observable.fromPromise(usernameUpdate).map( () => dedent` diff --git a/api-server/common/models/user.json b/api-server/common/models/user.json index 0f7a16fd54..fc5d1aaec4 100644 --- a/api-server/common/models/user.json +++ b/api-server/common/models/user.json @@ -74,10 +74,6 @@ }, "require": true }, - "displayUsername": { - "type": "string", - "default":"" - }, "about": { "type": "string", "default": "" diff --git a/api-server/server/boot/settings.js b/api-server/server/boot/settings.js index 9941ea06cb..4e366391bd 100644 --- a/api-server/server/boot/settings.js +++ b/api-server/server/boot/settings.js @@ -194,7 +194,7 @@ function createUpdateMyUsername(app) { user, body: { username } } = req; - if (username.toLowerCase() === user.username) { + if (username === user.username) { return res.json({ type: 'info', message: 'Username is already associated with this account' @@ -209,7 +209,7 @@ function createUpdateMyUsername(app) { }); } - const exists = await User.doesExist(username.toLowerCase()); + const exists = await User.doesExist(username); if (exists) { return res.json({ @@ -218,19 +218,16 @@ function createUpdateMyUsername(app) { }); } - return user.updateAttributes( - { username: username.toLowerCase(), displayUsername: username }, - err => { - if (err) { - res.status(500).json(standardErrorMessage); - return next(err); - } - return res.status(200).json({ - type: 'success', - message: `We have updated your username to ${username}` - }); + return user.updateAttribute('username', username, err => { + if (err) { + res.status(500).json(standardErrorMessage); + return next(err); } - ); + return res.status(200).json({ + type: 'success', + message: `We have updated your username to ${username}` + }); + }); }; } diff --git a/api-server/server/utils/auth.js b/api-server/server/utils/auth.js index 3960799da6..dd6d9aad0e 100644 --- a/api-server/server/utils/auth.js +++ b/api-server/server/utils/auth.js @@ -37,7 +37,6 @@ function createProfileAttributesFromGithub(profile) { return { name, username: username.toLowerCase(), - displayUsername: username, location, bio, website, diff --git a/api-server/server/utils/publicUserProps.js b/api-server/server/utils/publicUserProps.js index cde2aa6e9d..71becb1ac3 100644 --- a/api-server/server/utils/publicUserProps.js +++ b/api-server/server/utils/publicUserProps.js @@ -11,7 +11,6 @@ export const publicUserProps = [ 'about', 'calendar', 'completedChallenges', - 'displayUsername', 'githubProfile', 'isApisMicroservicesCert', 'isBackEndCert', diff --git a/client/src/client-only-routes/ShowProfileOrFourOhFour.js b/client/src/client-only-routes/ShowProfileOrFourOhFour.js index d5a76f423f..b8a01477d5 100644 --- a/client/src/client-only-routes/ShowProfileOrFourOhFour.js +++ b/client/src/client-only-routes/ShowProfileOrFourOhFour.js @@ -22,7 +22,6 @@ const propTypes = { navigate: PropTypes.func.isRequired, requestedUser: PropTypes.shape({ username: PropTypes.string, - displayUsername: PropTypes.string, profileUI: PropTypes.object }), showLoading: PropTypes.bool diff --git a/client/src/client-only-routes/ShowSettings.js b/client/src/client-only-routes/ShowSettings.js index ef216e2252..8b4e60be3b 100644 --- a/client/src/client-only-routes/ShowSettings.js +++ b/client/src/client-only-routes/ShowSettings.js @@ -48,7 +48,6 @@ const propTypes = { files: PropTypes.array }) ), - displayUsername: PropTypes.string, email: PropTypes.string, githubProfile: PropTypes.string, is2018DataVisCert: PropTypes.bool, @@ -122,7 +121,6 @@ export function ShowSettings(props) { toggleNightMode, user: { completedChallenges, - displayUsername, email, is2018DataVisCert, isApisMicroservicesCert, @@ -193,12 +191,9 @@ export function ShowSettings(props) { -

{`Account Settings for ${ - displayUsername ? displayUsername : username - }`}

+

+ {`Account Settings for ${username}`} +

diff --git a/client/src/components/profile/Profile.js b/client/src/components/profile/Profile.js index 7f1a3ef452..4369b8fc2f 100644 --- a/client/src/components/profile/Profile.js +++ b/client/src/components/profile/Profile.js @@ -27,7 +27,6 @@ const propTypes = { showPortfolio: PropTypes.bool, showTimeLine: PropTypes.bool }), - displayUsername: PropTypes.string, calendar: PropTypes.object, streak: PropTypes.shape({ current: PropTypes.number, @@ -122,15 +121,13 @@ function renderProfile(user) { picture, portfolio, about, - yearsTopContributor, - displayUsername + yearsTopContributor } = user; return ( : null} {showPortfolio ? : null} {showTimeLine ? ( - + ) : null} diff --git a/client/src/components/profile/components/Camper.js b/client/src/components/profile/components/Camper.js index 23b3724575..cb8d137ad9 100644 --- a/client/src/components/profile/components/Camper.js +++ b/client/src/components/profile/components/Camper.js @@ -11,7 +11,6 @@ import './camper.css'; const propTypes = { about: PropTypes.string, - displayUsername: PropTypes.string, githubProfile: PropTypes.string, isGithub: PropTypes.bool, isLinkedIn: PropTypes.bool, @@ -49,7 +48,6 @@ function joinArray(array) { function Camper({ name, username, - displayUsername, location, points, picture, @@ -76,7 +74,7 @@ function Camper({ /> ) : ( {displayUsername
-

- @{displayUsername ? displayUsername : username} -

+

@{username}

{name &&

{name}

} {location &&

{location}

} {about &&

{about}

} diff --git a/client/src/components/profile/components/TimeLine.js b/client/src/components/profile/components/TimeLine.js index d967ab8c09..be93b87895 100644 --- a/client/src/components/profile/components/TimeLine.js +++ b/client/src/components/profile/components/TimeLine.js @@ -27,7 +27,6 @@ const propTypes = { ) }) ), - displayUsername: PropTypes.string, username: PropTypes.string }; @@ -131,7 +130,6 @@ class TimelineInner extends Component { render() { const { completedMap, - displayUsername, idToNameMap, username, sortedTimeline, @@ -173,9 +171,9 @@ class TimelineInner extends Component { > - {`${ - displayUsername ? displayUsername : username - }'s Solution to ${idToNameMap.get(id).challengeTitle}`} + {`${username}'s Solution to ${ + idToNameMap.get(id).challengeTitle + }`} diff --git a/client/src/components/settings/Username.js b/client/src/components/settings/Username.js index b9ddf60a06..4242e78cf1 100644 --- a/client/src/components/settings/Username.js +++ b/client/src/components/settings/Username.js @@ -20,7 +20,6 @@ import FullWidthRow from '../helpers/FullWidthRow'; import { isValidUsername } from '../../../../utils/validate'; const propTypes = { - displayUsername: PropTypes.string, isValidUsername: PropTypes.bool, submitNewUsername: PropTypes.func.isRequired, username: PropTypes.string, @@ -55,9 +54,6 @@ class UsernameSettings extends Component { this.state = { isFormPristine: true, formValue: props.username, - formDisplayValue: props.displayUsername - ? props.displayUsername - : props.username, characterValidation: { valid: false, error: null }, submitClicked: false, isUserNew: tempUserRegex.test(props.username) @@ -88,23 +84,21 @@ class UsernameSettings extends Component { e.preventDefault(); const { submitNewUsername } = this.props; const { - formDisplayValue, + formValue, characterValidation: { valid } } = this.state; return this.setState({ submitClicked: true }, () => - valid ? submitNewUsername(formDisplayValue) : null + valid ? submitNewUsername(formValue) : null ); } handleChange(e) { e.preventDefault(); const { username, validateUsername } = this.props; - const newDisplayUsernameValue = e.target.value; - const newValue = newDisplayUsernameValue.toLowerCase(); + const newValue = e.target.value.toLowerCase(); return this.setState( { - formDisplayValue: newDisplayUsernameValue, formValue: newValue, isFormPristine: username === newValue, characterValidation: this.validateFormInput(newValue), @@ -166,7 +160,7 @@ class UsernameSettings extends Component { render() { const { isFormPristine, - formDisplayValue, + formValue, characterValidation: { valid, error }, submitClicked } = this.state; @@ -183,7 +177,7 @@ class UsernameSettings extends Component { diff --git a/client/src/redux/fetch-user-saga.js b/client/src/redux/fetch-user-saga.js index b8e3fa621c..abed96dc3f 100644 --- a/client/src/redux/fetch-user-saga.js +++ b/client/src/redux/fetch-user-saga.js @@ -20,11 +20,7 @@ function* fetchSessionUser() { } = yield call(getSessionUser); const appUser = user[result] || {}; yield put( - fetchUserComplete({ - user: appUser, - username: result, - sessionMeta - }) + fetchUserComplete({ user: appUser, username: result, sessionMeta }) ); } catch (e) { yield put(fetchUserError(e)); diff --git a/tools/scripts/seed/seedAuthUser.js b/tools/scripts/seed/seedAuthUser.js index d5efa7c2b1..61e54c43b9 100644 --- a/tools/scripts/seed/seedAuthUser.js +++ b/tools/scripts/seed/seedAuthUser.js @@ -45,7 +45,6 @@ MongoClient.connect(MONGOHQ_URL, { useNewUrlParser: true }, function( isBanned: false, isCheater: false, username: 'developmentuser', - displayUsername: 'DevelopmentUser', about: '', name: 'Development User', location: '',