From 29521de80e4420e8b93c3f6a900ae381fc366449 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 7 Jan 2022 16:10:53 -0600 Subject: [PATCH] Gate developers pages from non-developers --- app/soapbox/features/ui/index.js | 6 +++--- app/soapbox/features/ui/util/react_router_helpers.js | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/soapbox/features/ui/index.js b/app/soapbox/features/ui/index.js index e32b3700e..2f69499a9 100644 --- a/app/soapbox/features/ui/index.js +++ b/app/soapbox/features/ui/index.js @@ -322,9 +322,9 @@ class SwitchingColumnsArea extends React.PureComponent { - - - + + + diff --git a/app/soapbox/features/ui/util/react_router_helpers.js b/app/soapbox/features/ui/util/react_router_helpers.js index af0b40800..337f62e4e 100644 --- a/app/soapbox/features/ui/util/react_router_helpers.js +++ b/app/soapbox/features/ui/util/react_router_helpers.js @@ -8,6 +8,7 @@ import ColumnLoading from '../components/column_loading'; import ColumnForbidden from '../components/column_forbidden'; import BundleColumnError from '../components/bundle_column_error'; import BundleContainer from '../containers/bundle_container'; +import { getSettings } from 'soapbox/actions/settings'; import { isStaff, isAdmin } from 'soapbox/utils/accounts'; const mapStateToProps = state => { @@ -15,6 +16,7 @@ const mapStateToProps = state => { return { account: state.getIn(['accounts', me]), + settings: getSettings(state), }; }; @@ -27,9 +29,11 @@ class WrappedRoute extends React.Component { componentParams: PropTypes.object, layout: PropTypes.object, account: ImmutablePropTypes.map, + settings: ImmutablePropTypes.map.isRequired, publicRoute: PropTypes.bool, staffOnly: PropTypes.bool, adminOnly: PropTypes.bool, + developerOnly: PropTypes.bool, }; static defaultProps = { @@ -100,10 +104,11 @@ class WrappedRoute extends React.Component { } render() { - const { component: Component, content, account, publicRoute, staffOnly, adminOnly, ...rest } = this.props; + const { component: Component, content, account, settings, publicRoute, developerOnly, staffOnly, adminOnly, ...rest } = this.props; const authorized = [ account || publicRoute, + developerOnly ? settings.get('isDeveloper') : true, staffOnly ? account && isStaff(account) : true, adminOnly ? account && isAdmin(account) : true, ].every(c => c);