Skip to content

Commit

Permalink
fix: do not break LinkView for anonymous users (#786)
Browse files Browse the repository at this point in the history
* fix: do not break LinkView for anonymous users

* Update src/customizations/volto/components/theme/View/LinkView.jsx

Co-authored-by: Mauro Amico <mauro.amico@gmail.com>

* change variable name in LinkView

---------

Co-authored-by: Mauro Amico <mauro.amico@gmail.com>
  • Loading branch information
2 people authored and pnicolli committed Oct 16, 2024
1 parent ee269dd commit a45b7e6
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 userWithoutRoles = useSelector((state) =>
state.users?.user ? state.users.user?.roles?.length === 0 : true,
);

useEffect(() => {
if (!token || userIsSpidUser) {
if (!token || userWithoutRoles) {
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, userWithoutRoles]);
const { title, description, remoteUrl } = content;
const { openExternalLinkInNewTab } = config.settings;
const Container =
Expand Down

0 comments on commit a45b7e6

Please sign in to comment.