Skip to content

Commit

Permalink
fix: Enforce lowercase usernames for profile queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Bouncey authored and raisedadead committed Mar 6, 2019
1 parent 92208f7 commit c8f5b20
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions client/src/client-only-routes/ShowProfileOrFourOhFour.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ const propTypes = {
showLoading: PropTypes.bool
};

const createRequestedUserSelector = () => (state, { maybeUser }) =>
userByNameSelector(maybeUser)(state);
const createIsSessionUserSelector = () => (state, { maybeUser }) =>
maybeUser === usernameSelector(state);
const createRequestedUserSelector = () => (state, { maybeUser = '' }) =>
userByNameSelector(maybeUser.toLowerCase())(state);
const createIsSessionUserSelector = () => (state, { maybeUser = '' }) =>
maybeUser.toLowerCase() === usernameSelector(state);

const makeMapStateToProps = () => (state, props) => {
const requestedUserSelector = createRequestedUserSelector();
Expand Down
5 changes: 3 additions & 2 deletions client/src/redux/fetch-user-saga.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ function* fetchSessionUser() {
}
}

function* fetchOtherUser({ payload: maybeUser }) {
function* fetchOtherUser({ payload: maybeUser = '' }) {
try {
const { data } = yield call(getUserProfile, maybeUser);
const maybeUserLC = maybeUser.toLowerCase();
const { data } = yield call(getUserProfile, maybeUserLC);

const { entities: { user = {} } = {}, result = '' } = data;
const otherUser = user[result] || {};
Expand Down
2 changes: 1 addition & 1 deletion tools/scripts/seed/seedAuthUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ MongoClient.connect(MONGOHQ_URL, { useNewUrlParser: true }, function(
progressTimestamps: [],
isBanned: false,
isCheater: false,
username: 'DevelopmentUser',
username: 'developmentuser',
about: '',
name: 'Development User',
location: '',
Expand Down

0 comments on commit c8f5b20

Please sign in to comment.