Skip to content

Commit

Permalink
Merge pull request #29090 from c3024/28591-check-currentUser-with-acc…
Browse files Browse the repository at this point in the history
…ountID

check currentUser with accountID
  • Loading branch information
pecanoro authored Oct 11, 2023
2 parents a3247b2 + 525c50e commit 5f12eee
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
21 changes: 10 additions & 11 deletions src/pages/DetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,10 @@ const propTypes = {
/** Route params */
route: matchType.isRequired,

/** Login list for the user that is signed in */
loginList: PropTypes.shape({
/** Date login was validated, used to show info indicator status */
validatedDate: PropTypes.string,

/** Field-specific server side errors keyed by microtime */
errorFields: PropTypes.objectOf(PropTypes.objectOf(PropTypes.string)),
/** Session info for the currently logged in user. */
session: PropTypes.shape({
/** Currently logged in user accountID */
accountID: PropTypes.number,
}),

...withLocalizePropTypes,
Expand All @@ -63,7 +60,9 @@ const propTypes = {
const defaultProps = {
// When opening someone else's profile (via deep link) before login, this is empty
personalDetails: {},
loginList: {},
session: {
accountID: 0,
},
};

/**
Expand Down Expand Up @@ -123,7 +122,7 @@ function DetailsPage(props) {
const phoneNumber = getPhoneNumber(details);
const phoneOrEmail = isSMSLogin ? getPhoneNumber(details) : details.login;

const isCurrentUser = _.keys(props.loginList).includes(details.login);
const isCurrentUser = props.session.accountID === details.accountID;

return (
<ScreenWrapper testID={DetailsPage.displayName}>
Expand Down Expand Up @@ -225,8 +224,8 @@ export default compose(
personalDetails: {
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
},
loginList: {
key: ONYXKEYS.LOGIN_LIST,
session: {
key: ONYXKEYS.SESSION,
},
}),
)(DetailsPage);
21 changes: 10 additions & 11 deletions src/pages/ProfilePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,25 @@ const propTypes = {
/** Route params */
route: matchType.isRequired,

/** Login list for the user that is signed in */
loginList: PropTypes.shape({
/** Phone/Email associated with user */
partnerUserID: PropTypes.string,
}),

/** Indicates whether the app is loading initial data */
isLoadingReportData: PropTypes.bool,

/** Session info for the currently logged in user. */
session: PropTypes.shape({
/** Currently logged in user accountID */
accountID: PropTypes.number,
}),

...withLocalizePropTypes,
};

const defaultProps = {
// When opening someone else's profile (via deep link) before login, this is empty
personalDetails: {},
loginList: {},
isLoadingReportData: true,
session: {
accountID: 0,
},
};

/**
Expand Down Expand Up @@ -122,7 +124,7 @@ function ProfilePage(props) {
const phoneNumber = getPhoneNumber(details);
const phoneOrEmail = isSMSLogin ? getPhoneNumber(details) : login;

const isCurrentUser = _.keys(props.loginList).includes(login);
const isCurrentUser = props.session.accountID === accountID;
const hasMinimumDetails = !_.isEmpty(details.avatar);
const isLoading = lodashGet(details, 'isLoading', false) || _.isEmpty(details) || props.isLoadingReportData;

Expand Down Expand Up @@ -290,9 +292,6 @@ export default compose(
personalDetails: {
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
},
loginList: {
key: ONYXKEYS.LOGIN_LIST,
},
isLoadingReportData: {
key: ONYXKEYS.IS_LOADING_REPORT_DATA,
},
Expand Down

0 comments on commit 5f12eee

Please sign in to comment.