Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Stefano Beretta 91 posts 235 karma points
    Jan 18, 2018 @ 07:16
    Stefano Beretta
    0

    IContentFinder: show protected node without authentication

    Hi everyone!

    I'm implementing my custom Content Finder and I'm almost done, but there's a problem: the code retrieve correctly the node, but it's protected (role based) and when I set the PublishedContentRequest.PublishedContent to the protected node I've found, Umbraco (correctly) redirect me to the login page. Is there a way to temporary remove this protection?

    I've the following structure:

    HP

    • SubHome1 (MultinodePicker to ProtectedNode1 and ProtectedNode2)
    • SubHome2
    • ...
    • ProtectedHP
      • ProtectedNode1
      • ProtectedNode2
      • ...

    The purpose is to have "virtual pages" under SubHome1 (/SubHome1/ProtectedNode1 and /SubHome1/ProtectedNode2) without duplicating the nodes, so I can show the user some of my protected pages.

    The IContentFinder works, it find the protected nodes, but I'm always redirected to the login page.

     public class PreviewsContentFinder : IContentFinder
        {
            public bool TryFindContent(PublishedContentRequest request)
            {
                //find my protected node from the last url segment
                //...
                if(nodeIsFound)
                {
                     request.PublishedContent = foundNode; //foundNode is my protected node
                     //some other istruction to avoid redirect to the login page
    
                }
                return nodeIsFound;
            }
        }
    

    Thank you S

  • Dave Woestenborghs 3325 posts 11170 karma points MVP 5x admin c-trib
    Jan 18, 2018 @ 09:58
    Dave Woestenborghs
    0

    Hi Stefano,

    Maybe a stupid question ? But why do you want to show a page that is protected without the user having to log in ? Doesn't that make the proctection useless ?

    Dave

  • Stefano Beretta 91 posts 235 karma points
    Jan 18, 2018 @ 10:55
    Stefano Beretta
    0

    Same question I asked to my customer when he told me "Ok, now remove the protection from these pages!"... He wanted neither duplicate nor move the node so I thought about the content finder... I know it's kinda weird...

  • Nik 1413 posts 6212 karma points MVP 3x c-trib
    Jan 18, 2018 @ 11:10
    Nik
    0

    I don't think you are going to be able to achieve what you are after directly because the parent node is protected. However, what about if you created a "virtual" page. This would have a different url, but instead of using the content finder approach you load the data via the Umbraco cache using a partial view. You have full control on this I think.

    You'd have to put some meta bits in place as the same content would be available on two urls, but you wouldn't have duplication in the back office, so a single point of managing it.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies