Skip to content
Permalink
Browse files

fix: Enforce lowercase usernames for profile queries

  • Loading branch information...
Bouncey authored and raisedadead committed Mar 1, 2019
1 parent 92208f7 commit c8f5b20b71914dd645dca714a367aaec4efc3d9f
@@ -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();
@@ -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] || {};
@@ -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: '',

0 comments on commit c8f5b20

Please sign in to comment.
You can’t perform that action at this time.