Copied to clipboard

Flag this post as spam?

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


  • SlothMonkey 17 posts 56 karma points
    Jan 26, 2015 @ 16:44
    SlothMonkey
    0

    Restricting page access

    I have one page I only want certain members to have access to. This page is currently accessed by a partial view that is auto populated by checking for page nodes in my site.

    Hhere is my partial view

      <ul class="nav navbar-nav navbar-right">
                @foreach (var page in root.Children.Where("visible"))
                {
                    if (page.Children.Count() == 0 || page.hideChildNodes == true)
                    {
                        <li class="@(page.IsAncestorOrSelf(CurrentPage) ? "active" : null)">
                            <a href="@page.Url">@page.Name</a>
                        </li>
                    }
                }
            </ul>
    

    How can I get it so that this navigation bar is only filled with views allowed to that member?

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Jan 26, 2015 @ 17:04
    Alex Skrypnyk
    0

    Hi SlothMonkey,

    You have to use method .MemberHasAccess(int nodeId, string path);

    Methods which you show at your code snippet, just checked "umbracoNaviHide" fields for all members and not-authenticated users.

    Thanks

  • SlothMonkey 17 posts 56 karma points
    Jan 26, 2015 @ 17:29
    SlothMonkey
    0

    I'm not sure I understand what your saying with MemberHasAccess

    In my final site I am going to have one page that is only visible to members that have, for this example, a property that says Can View Page. This property will get checked to true should it meet with its required parameter but the property will be on every member.

    Is there a way I can check against this "Can View Page" property in the same way in which I check to see if the page is visible?

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Jan 27, 2015 @ 10:24
    Richard Soeteman
    0

    Why don't you use the default protection of Umbraco? Right click on node public access and you can select member groups that has access and you can use the snippets in the template editors to create login forms for you.

    People that don't have access will be automatically redirected to the login page. and you can use the Methods Dennnis mentioned to exclude pages from navigation.

    As a bonus you get the restricted icon in the backoffice to see which pages are protected.

    Best,

    Richard

Please Sign in or register to post replies

Write your reply to:

Draft