Skip to content

Commit

Permalink
fix: added owner check for WS pages
Browse files Browse the repository at this point in the history
  • Loading branch information
BhuvaneshPatil committed Jul 12, 2023
1 parent 8923cb0 commit be7b6a0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/pages/ReimbursementAccount/ReimbursementAccountPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import * as ReimbursementAccountProps from './reimbursementAccountPropTypes';
import reimbursementAccountDraftPropTypes from './ReimbursementAccountDraftPropTypes';
import withPolicy from '../workspace/withPolicy';
import FullPageNotFoundView from '../../components/BlockingViews/FullPageNotFoundView';
import * as Policy from '../../libs/actions/Policy';

const propTypes = {
/** Plaid SDK token to use to initialize the widget */
Expand Down Expand Up @@ -330,12 +331,13 @@ class ReimbursementAccountPage extends React.Component {
const currentStep = achData.currentStep || CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT;
const policyName = lodashGet(this.props.policy, 'name');

if (_.isEmpty(this.props.policy)) {
if (_.isEmpty(this.props.policy) || !Policy.isPolicyOwner(this.props.policy)) {
return (
<ScreenWrapper>
<FullPageNotFoundView
shouldShow
onBackButtonPress={() => Navigation.navigate(ROUTES.SETTINGS_WORKSPACES)}
subtitleKey={_.isEmpty(this.props.policy) ? undefined : 'workspace.common.notAuthorized'}
shouldShowLink
/>
</ScreenWrapper>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/workspace/WorkspaceInviteMessagePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ class WorkspaceInviteMessagePage extends React.Component {
return (
<ScreenWrapper includeSafeAreaPaddingBottom={false}>
<FullPageNotFoundView
shouldShow={_.isEmpty(this.props.policy)}
shouldShow={_.isEmpty(this.props.policy) || !Policy.isPolicyOwner(this.props.policy)}
subtitleKey={_.isEmpty(this.props.policy) ? undefined : 'workspace.common.notAuthorized'}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)}
>
<HeaderWithBackButton
Expand Down
3 changes: 2 additions & 1 deletion src/pages/workspace/WorkspaceInvitePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ class WorkspaceInvitePage extends React.Component {
const sections = didScreenTransitionEnd ? this.getSections() : [];
return (
<FullPageNotFoundView
shouldShow={_.isEmpty(this.props.policy)}
shouldShow={_.isEmpty(this.props.policy) || !Policy.isPolicyOwner(this.props.policy)}
subtitleKey={_.isEmpty(this.props.policy) ? undefined : 'workspace.common.notAuthorized'}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)}
>
<HeaderWithBackButton
Expand Down
3 changes: 2 additions & 1 deletion src/pages/workspace/WorkspaceMembersPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,8 @@ function WorkspaceMembersPage(props) {
>
{({safeAreaPaddingBottomStyle}) => (
<FullPageNotFoundView
shouldShow={_.isEmpty(props.policy)}
shouldShow={_.isEmpty(props.policy) || !Policy.isPolicyOwner(props.policy)}
subtitleKey={_.isEmpty(props.policy) ? undefined : 'workspace.common.notAuthorized'}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)}
>
<HeaderWithBackButton
Expand Down

0 comments on commit be7b6a0

Please sign in to comment.