Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not break LinkView for anonymous users #786

Merged
merged 3 commits into from
Oct 16, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) =>
pnicolli marked this conversation as resolved.
Show resolved Hide resolved
state.users?.user ? state.users.user?.roles?.length === 0 : true,
mamico marked this conversation as resolved.
Show resolved Hide resolved
);

useEffect(() => {
if (!token || userIsSpidUser) {
if (!token || isReader) {
mamico marked this conversation as resolved.
Show resolved Hide resolved
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]);
mamico marked this conversation as resolved.
Show resolved Hide resolved
const { title, description, remoteUrl } = content;
const { openExternalLinkInNewTab } = config.settings;
const Container =
Expand Down
Loading