Skip to content

Commit

Permalink
Fix site setup access check by using @actions endpoint to validate pe…
Browse files Browse the repository at this point in the history
…rmissions.
  • Loading branch information
Faakhir30 committed Oct 17, 2024
1 parent 5660ae4 commit 5bfe9f5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions packages/volto/news/6355.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix site setup access check by using @actions endpoint to validate permissions. @Faakhir30
13 changes: 6 additions & 7 deletions packages/volto/src/components/manage/Toolbar/PersonalTools.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@ import { FormattedMessage, useIntl, defineMessages } from 'react-intl';
import { Icon } from '@plone/volto/components';
import { getUser } from '@plone/volto/actions';
import { Pluggable } from '@plone/volto/components/manage/Pluggable';
import {
expandToBackendURL,
getBaseUrl,
userHasRoles,
} from '@plone/volto/helpers';
import { expandToBackendURL, getBaseUrl } from '@plone/volto/helpers';
import logoutSVG from '@plone/volto/icons/log-out.svg';
import rightArrowSVG from '@plone/volto/icons/right-key.svg';
import backSVG from '@plone/volto/icons/back.svg';
import cameraSVG from '@plone/volto/icons/camera.svg';
import { find } from 'lodash';

const messages = defineMessages({
back: {
Expand Down Expand Up @@ -50,7 +47,9 @@ const PersonalTools = (props) => {
const token = useSelector((state) => state.userSession.token, shallowEqual);
const user = useSelector((state) => state.users.user);
const userId = token ? jwtDecode(token).sub : '';

const siteSetupAction = find(props.actions.user, {
id: 'plone_setup',
});
useEffect(() => {
dispatch(getUser(userId));
}, [dispatch, userId]);
Expand Down Expand Up @@ -127,7 +126,7 @@ const PersonalTools = (props) => {
</button>
</li>

{userHasRoles(user, ['Site Administrator', 'Manager']) && (
{siteSetupAction && (
<li>
<Link to="/controlpanel">
<FormattedMessage id="Site Setup" defaultMessage="Site Setup" />
Expand Down
1 change: 1 addition & 0 deletions packages/volto/src/components/manage/Toolbar/Toolbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ class Toolbar extends Component {
theToolbar={this.toolbarWindow}
key={`personalToolsComponent-${index}`}
closeMenu={this.closeMenu}
actions={this.props.actions}
content={
toolbarComponents[component].contentAsProps
? this.props.content
Expand Down

0 comments on commit 5bfe9f5

Please sign in to comment.