Copied to clipboard

Flag this post as spam?

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


  • Lander Debeuf 23 posts 125 karma points
    Oct 23, 2019 @ 13:28
    Lander Debeuf
    0

    Node Public Access from Backend

    Umbraco 8.2.0

    I am protecting my published content with the "Public Access" option in Umbraco, you can set group access to every node, you can select the member groups that have access, and if they have no access, they are redirected to the login page or the error page respectivly.

    I want to know in my controller if the logged in member has access to a certain page. (In order to build a clean menu, only showing the items he has access to)

    if (Umbraco.MemberHasAccess(childPage.Url))
    

    but this seems to return true all the time while the page is a page the current logged in member has no access to, it still returns true.

    But when the member is really accessing the page he is redirected to the Login page.

    And i can't seem to find a method to retrieve the Public Access settings of a page in the backend.

    Could someone help me?

  • Marc Goodson 2155 posts 14408 karma points MVP 9x c-trib
    Oct 26, 2019 @ 07:15
    Marc Goodson
    0

    Hi Lander

    The MemberHasAccess method is expecting the 'Path' of the Umbraco node that you are trying to determine whether the current logged in Member has access to view.

    The Path property isn't the url to the content item (I know the word path suggest this!!!) but instead every Umbraco item has a special property called Path, which is actually a comma seperated list of all the ids of the ancestor parent nodes all they way up the content tree to the root, eg -1,234,2345,23456 etc

    So your check should be in the format:

    if (Umbraco.MemberHasAccess(childPage.Path))
    

    regards

    Marc

Please Sign in or register to post replies

Write your reply to:

Draft