Copied to clipboard

Flag this post as spam?

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


  • Damian Green 452 posts 1433 karma points
    Oct 02, 2014 @ 22:16
    Damian Green
    0

    Is there an extension point for the access checking on a page?

    I want to be able to setup umbraco so that if someone is in a certain group then prevent access to areas protected by another group - so the member can be removed from access temporarily.

    At the mo you cant do that with the membership so ive been looking to see if there were any events I could hook into that i could perform this check and redirect to a login/or other page rather than the controlled page that they woudl still have access to.

    I cant just disable login because i need this to stay and i don't want to change the other groups they belong to if possible.

    I have been looking at the application events but nothing seems to be hooked into the authentication that allows the authentication to be rejected.

    Any ideas where i could do this?

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Oct 02, 2014 @ 22:39
    Dennis Aaen
    0

    Hi Damain,

    I must say that I am not a backend developer, but maybe the Umbraco Api - Authorization or the MemberService can help you.

    You can find the documentation for the Umbraco Api - Authorization here: http://our.umbraco.org/documentation/Reference/WebApi/authorization and the MemberService here: http://our.umbraco.org/documentation/Reference/Management-v6/Services/MemberService

    Hope this can help you a step further.

    /Dennis

  • Damian Green 452 posts 1433 karma points
    Oct 02, 2014 @ 22:51
    Damian Green
    0

    Hi Dennis,

    Those two items deal with access to web api and the management of the members. I need to hook into the point at which a page is checked to see if the user has access.

    I am also using the publishedcontentmodel which may add further complications.

    Thanks for your ideas though.

    Cheers, Damian

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Oct 03, 2014 @ 10:12
    Dave Woestenborghs
    0

    Hi Damian,

    It is not clear to me if you want this in the backend or the frontend ?

    Dave

  • Damian Green 452 posts 1433 karma points
    Oct 03, 2014 @ 11:19
    Damian Green
    0

    Hi Dave,

    This is members so when a member accesses a page on the front end of the website.

    So basically i want:

    when a user access a page

    that is protected by a member group

    and their accent allows access to this page

    but the user is in the banned group

    redirect to the account banned paged

    otherwise let them view the page

    So i need to hook into the point where the member and page are authorised so i can cancel the authorisation and redirect if required.

    Is that clear now?

    Cheers Damian

  • Damian Green 452 posts 1433 karma points
    Oct 03, 2014 @ 11:59
    Damian Green
    100

    Sussed a way to do it! :)

    Basically hook in the to PublishedContentRequest!

    public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            PublishedContentRequest.Prepared += PublishedContentRequest_Prepared;
        }
    
        private void PublishedContentRequest_Prepared(object sender, EventArgs e)
        {
            // Check to make sure the request is valid
            var request = sender as PublishedContentRequest;
            if (request == null || !request.HasPublishedContent)
                return;
    
            //See if member is in lapsed role
            //
            var lapsed = Roles.IsUserInRole("Banned");
    
            if (!lapsed) return;
    
            var pageIsProtected = Access.IsProtected(request.PublishedContent.Id, request.PublishedContent.Path);
    
            // Bounce to banned page
            //
            if (pageIsProtected)                    
                request.SetRedirect("/account/lapsed", 302);
        }
    
Please Sign in or register to post replies

Write your reply to:

Draft