1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Assigning a user to a role

Assigning a user to a role

3 posts, 0 answered
  1. Pierre Alain
    Pierre Alain avatar
    38 posts
    Registered:
    10 Jun 2008
    27 Apr 2012
    Link to this post
    I've created a role (Affiliates) and set some page permission to require that role.

    When a user enrolls has an affiliate, I assign him to that role, as such:
    RoleManager roleManager = RoleManager.GetManager();
    Role role = roleManager.GetRole("Affiliates");
     
    roleManager.Provider.SuppressSecurityChecks = true;
    try
    {
        roleManager.AddUserToRole(user, role);
        roleManager.SaveChanges();
    }
    finally
    {
        roleManager.Provider.SuppressSecurityChecks = false;
    }

    I can see in the back-end that the user is assigned to the role, but he still doesn't have access to restricted page. They don't show up in the navigation and, when going directly to the url, get redirected to the login page.

    If I wait a while, then it seems to work. I'm not sure if it's an application restart, because I tried that with no success.

    Is this normal? Is there something I am not doing?
  2. Ethan
    Ethan avatar
    3 posts
    Registered:
    22 Jun 2012
    26 Jun 2012
    Link to this post
    I believe Sitefinity does some kind of caching on user roles. For example, when you de-admin someone, you need force log them out or else Sitefinity will still treat them as admin with all privileges.

    If the Affiliate logs out and logs back in, does that give him proper permissions?
  3. Pierre Alain
    Pierre Alain avatar
    38 posts
    Registered:
    10 Jun 2008
    27 Jun 2012
    Link to this post
    It does look like something like that, although logging out than back in does not solve the problem all the time.
3 posts, 0 answered