fix: Enforce lowercase usernames for profile queries

This commit is contained in:
Bouncey
2019-03-01 12:58:34 +00:00
committed by mrugesh mohapatra
parent 92208f7c23
commit c8f5b20b71
3 changed files with 8 additions and 7 deletions

View File

@@ -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();

View File

@@ -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] || {};