Copied to clipboard

Flag this post as spam?

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


  • Kris Janssen 210 posts 569 karma points c-trib
    Jun 19, 2014 @ 00:14
    Kris Janssen
    0

    U7.1.4 Dynamic HasAccess() IsProtected() not working

    I have a site set up (upgraded from U6.x to U7.1.4 where several pages feature role based protection.

    This seems to work, trying to access these pages brings up the login dialog.

    Now, I tried to modify my navigation Partial view macro to only render items that are accessible:

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    
    <ul>
        @{ 
            var homeNode = CurrentPage.AncestorOrSelf(1);
        }
    
            <li class=""><a href="@homeNode.Url">@homeNode.Name</a></li>
    
        @foreach (var page in CurrentPage.AncestorOrSelf(1).Children.Where("Visible"))
            {
        if (page.Children.Any())
    
    ...
    

    Trying to add .Where(Visible && HasAccess) renders no nodes at all (although they are clearly in my site) .Where(Visible && !IsProtected) likewise does not work.

    Sticking with .Where("Visible") instead relying on an if statement such as page.HasAccess() or page.IsProtected also does not work. These methods always seem to return nothing at all.

    Is this a bug or is something wrong with my setup?

    Needless to say, this is rather urgent :s

    Cheers,

    Kris

  • Kris Janssen 210 posts 569 karma points c-trib
    Jun 19, 2014 @ 00:22
    Kris Janssen
    0

    A small update:

    @Umbraco.MemberHasAccess(page.Id, page.Path)
    

    In exactly the same script does in fact yield the expected "True" or "False" values...

    Anybody with an idea?

  • Kris Janssen 210 posts 569 karma points c-trib
    Jun 20, 2014 @ 02:37
    Kris Janssen
    100

    Anyone on the core team that could comment on this?

    Cheers,

    Kris

Please Sign in or register to post replies

Write your reply to:

Draft