Skip to content

Commit

Permalink
fix: do not break LinkView for anonymous users
Browse files Browse the repository at this point in the history
  • Loading branch information
cekk committed Oct 11, 2024
1 parent 5091d2d commit 95d70cd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/customizations/volto/components/theme/View/LinkView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ import config from '@plone/volto/registry';

const LinkView = ({ token, content }) => {
const history = useHistory();
const userIsSpidUser = useSelector(
(state) => state.users.user.roles.length === 0,
const isReader = useSelector((state) =>
state.users.user ? state.users.user.roles.length === 0 : true,
);

useEffect(() => {
if (!token || userIsSpidUser) {
if (!token || isReader) {
const { remoteUrl } = content;
if (isInternalURL(remoteUrl)) {
history.replace(flattenToAppURL(remoteUrl));
} else if (!__SERVER__) {
window.location.href = flattenToAppURL(remoteUrl);
}
}
}, [content, history, token, userIsSpidUser]);
}, [content, history, token, isReader]);
const { title, description, remoteUrl } = content;
const { openExternalLinkInNewTab } = config.settings;
const Container =
Expand Down

0 comments on commit 95d70cd

Please sign in to comment.