Assigning a user to a role

Posted by Community Admin on 04-Aug-2018 13:48

Assigning a user to a role

All Replies

Posted by Community Admin on 27-Apr-2012 00:00

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?

Posted by Community Admin on 26-Jun-2012 00:00

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?

Posted by Community Admin on 27-Jun-2012 00:00

It does look like something like that, although logging out than back in does not solve the problem all the time.

This thread is closed