Copied to clipboard

Flag this post as spam?

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


  • Peter Nielsen 159 posts 257 karma points
    Jun 18, 2014 @ 12:52
    Peter Nielsen
    0

    Custom Membership- & RoleProvider to secure pages

    Hi people

    I'm working on a custom membership provider and a custom role provider.

    I have added it to the web.config, and I can login and get the roles for my user. But what I can not do, is to make the umbraco pages to recognize the roles that the user have.

    I have created a role based access on a page, and if I go the page I get the login window as I should. It seems that I can login with my user. But when I do, it doesn't change the content on the site from the loginpage to the real site. So it seems that I don't have access.

    If I do this:

    @{
        var curUser = Membership.GetUser();
    }
    @if(curUser != null) {
        <p>Username: @curUser.UserName</p>
    }
    
    
    <p>Roles:</p>
    @foreach(var role in Roles.GetRolesForUser(curUser.UserName)) {
        <p>Role: @role</p>
    }
    

    I get my username and the rolename outputted correctly. So why will Umbraco not grant me access the page content?

    Cheers

    Peter

  • Peter Nielsen 159 posts 257 karma points
    Aug 11, 2014 @ 11:31
    Peter Nielsen
    0

    I wrote this before the holidays... Still having the same problem!

    Would it be any less secure if I did something like this:

    @if(Array.IndexOf(Roles.GetRolesForUser(curUser.UserName), "MyRole") == -1) {
      Response.Redirect("/?msg=notLoggedIn");
    }
    

    That was the way I did with classic ASP in the old days ;) Or could there be some secure issues here?

    Cheers

    Peter

  • Conny Carlman 4 posts 24 karma points
    Aug 18, 2014 @ 16:38
    Conny Carlman
    0

    Hi, I have the same problem after upgrading from Umbraco 7.02 to 7.1.4.

    I have tried inheriting from both the new Umbraco.Web.Security.Providers.MembersMembershipProvider/MembersRoleProvider, and the deprecated umbraco.providers.members.UmbracoMembershipProvider/UmbracoRoleProvider.

    Seems like a bug (or a breaking change, but I can't find any info about that).

    What Umbraco version do you use?

     

  • Bruce 17 posts 82 karma points
    Nov 16, 2014 @ 13:17
    Bruce
    0

    I was just writing about this myself. I'm also getting the same issue. Custom Membership. Log in, role exists, user exists but Umbraco seems to be ignoring it (exactly the same as Peter is experiencing). The exact same code has previously worked great for earlier versions of Umbraco (versions 4.5 - 4.7).

    Is this a bug? Or is there a newer way to write custom membership in 7.1.x (I'm using 7.1.8).

    Just like Conny, I can't find any information about this.

    Thanks

     

  • Patrick Livbom 6 posts 27 karma points
    Feb 01, 2019 @ 13:11
    Patrick Livbom
    0

    Really old post but i am kind of stuck here too, could someone push me in the right direction?

Please Sign in or register to post replies

Write your reply to:

Draft