Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue 24522: User should not access add debit card with no permissions #25652

Merged
merged 4 commits into from
Aug 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not A Blocker, but it would have been nice to add a comment explaining why this block is here. Perhaps you can do that in a followup PR?

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