Search code examples
umbracoumbraco7

Umbraco - Using preview functionality with user who doesn't have access to content section


I wanted to make use of the built in Umbraco content preview functionality however, it doesn't work with user's who do not have access to the content section.

I have created a custom section which allows users to edit a content node and save the changes. Due to my requirements it is not possible to allow these users access to the content directly section, even if I further restrict their permissions.

I added a button in my custom section which redirects users to the preview url of a specific content node. This works fine if the user has access to the content section, but if not an error is displayed saying: 'The current user doesn't have access to the section/app 'content''.

Is there a way to fix this or a work around that I could use?

Thank you in advance.


Solution

  • There's not really a fix for this one, as it's correctly applying the permissions to the preview functionality. You SHOULD only be able to access a preview if you have access to the content section, as the preview is part of that section.

    You MIGHT be able to get away with giving the user access to the content section, but setting their start node to be a dummy node that they don't have any permissions to do anything on, it depends on how aggressively it checks you access (whether it just checks you have access to the section, or whether it checks you have access to the actual page as well).

    If you 100% can't give the users access to the content section, another option would be to write your own custom preview function, based on the functionality of the built in preview, but without the need for the user to have access to the content section. The source for the functionality can be found in the main Github repo.