sforkowany z mirror/soapbox
Gate developers pages from non-developers
rodzic
d270e92927
commit
29521de80e
|
@ -322,9 +322,9 @@ class SwitchingColumnsArea extends React.PureComponent {
|
||||||
<WrappedRoute path='/admin/users' staffOnly page={AdminPage} component={UserIndex} content={children} exact />
|
<WrappedRoute path='/admin/users' staffOnly page={AdminPage} component={UserIndex} content={children} exact />
|
||||||
<WrappedRoute path='/info' page={EmptyPage} component={ServerInfo} content={children} />
|
<WrappedRoute path='/info' page={EmptyPage} component={ServerInfo} content={children} />
|
||||||
|
|
||||||
<WrappedRoute path='/developers/apps/create' page={DefaultPage} component={CreateApp} content={children} />
|
<WrappedRoute path='/developers/apps/create' developerOnly page={DefaultPage} component={CreateApp} content={children} />
|
||||||
<WrappedRoute path='/developers/settings_store' page={DefaultPage} component={SettingsStore} content={children} />
|
<WrappedRoute path='/developers/settings_store' developerOnly page={DefaultPage} component={SettingsStore} content={children} />
|
||||||
<WrappedRoute path='/developers' page={DefaultPage} component={Developers} content={children} />
|
<WrappedRoute path='/developers' developerOnly page={DefaultPage} component={Developers} content={children} />
|
||||||
<WrappedRoute path='/error' page={EmptyPage} component={IntentionalError} content={children} />
|
<WrappedRoute path='/error' page={EmptyPage} component={IntentionalError} content={children} />
|
||||||
|
|
||||||
<WrappedRoute path='/donate/crypto' publicRoute page={DefaultPage} component={CryptoDonate} content={children} />
|
<WrappedRoute path='/donate/crypto' publicRoute page={DefaultPage} component={CryptoDonate} content={children} />
|
||||||
|
|
|
@ -8,6 +8,7 @@ import ColumnLoading from '../components/column_loading';
|
||||||
import ColumnForbidden from '../components/column_forbidden';
|
import ColumnForbidden from '../components/column_forbidden';
|
||||||
import BundleColumnError from '../components/bundle_column_error';
|
import BundleColumnError from '../components/bundle_column_error';
|
||||||
import BundleContainer from '../containers/bundle_container';
|
import BundleContainer from '../containers/bundle_container';
|
||||||
|
import { getSettings } from 'soapbox/actions/settings';
|
||||||
import { isStaff, isAdmin } from 'soapbox/utils/accounts';
|
import { isStaff, isAdmin } from 'soapbox/utils/accounts';
|
||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
|
@ -15,6 +16,7 @@ const mapStateToProps = state => {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
account: state.getIn(['accounts', me]),
|
account: state.getIn(['accounts', me]),
|
||||||
|
settings: getSettings(state),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -27,9 +29,11 @@ class WrappedRoute extends React.Component {
|
||||||
componentParams: PropTypes.object,
|
componentParams: PropTypes.object,
|
||||||
layout: PropTypes.object,
|
layout: PropTypes.object,
|
||||||
account: ImmutablePropTypes.map,
|
account: ImmutablePropTypes.map,
|
||||||
|
settings: ImmutablePropTypes.map.isRequired,
|
||||||
publicRoute: PropTypes.bool,
|
publicRoute: PropTypes.bool,
|
||||||
staffOnly: PropTypes.bool,
|
staffOnly: PropTypes.bool,
|
||||||
adminOnly: PropTypes.bool,
|
adminOnly: PropTypes.bool,
|
||||||
|
developerOnly: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
|
@ -100,10 +104,11 @@ class WrappedRoute extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
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 = [
|
const authorized = [
|
||||||
account || publicRoute,
|
account || publicRoute,
|
||||||
|
developerOnly ? settings.get('isDeveloper') : true,
|
||||||
staffOnly ? account && isStaff(account) : true,
|
staffOnly ? account && isStaff(account) : true,
|
||||||
adminOnly ? account && isAdmin(account) : true,
|
adminOnly ? account && isAdmin(account) : true,
|
||||||
].every(c => c);
|
].every(c => c);
|
||||||
|
|
Ładowanie…
Reference in New Issue