Skip to content

Commit

Permalink
Merge pull request #25652 from makiour/makiour@issue-debit-card
Browse files Browse the repository at this point in the history
Fix Issue 24522: User should not access add debit card with no permissions
  • Loading branch information
flodnv authored Aug 24, 2023
2 parents 9a6c643 + 964bb58 commit 00efce4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/pages/settings/Wallet/AddDebitCardPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,24 @@ import Form from '../../../components/Form';
import Navigation from '../../../libs/Navigation/Navigation';
import ROUTES from '../../../ROUTES';
import usePrevious from '../../../hooks/usePrevious';
import NotFoundPage from '../../ErrorPage/NotFoundPage';
import Permissions from '../../../libs/Permissions';

const propTypes = {
/* Onyx Props */
formData: PropTypes.shape({
setupComplete: PropTypes.bool,
}),

/** List of betas available to current user */
betas: PropTypes.arrayOf(PropTypes.string),
};

const defaultProps = {
formData: {
setupComplete: false,
},
betas: [],
};

function DebitCardPage(props) {
Expand Down Expand Up @@ -94,6 +100,10 @@ function DebitCardPage(props) {
return errors;
};

if (!Permissions.canUseWallet(props.betas)) {
return <NotFoundPage />;
}

return (
<ScreenWrapper
onEntryTransitionEnd={() => nameOnCardRef.current && nameOnCardRef.current.focus()}
Expand Down Expand Up @@ -194,4 +204,7 @@ export default withOnyx({
formData: {
key: ONYXKEYS.FORMS.ADD_DEBIT_CARD_FORM,
},
betas: {
key: ONYXKEYS.BETAS,
},
})(DebitCardPage);

0 comments on commit 00efce4

Please sign in to comment.