More in this section
Forums / General Discussions / Updating Nav menu after role change

Updating Nav menu after role change

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
2 posts, 0 answered
  1. Barend
    Barend avatar
    2 posts
    Registered:
    16 May 2014
    10 Sep 2014
    Link to this post

    01.roleManager.Provider.SuppressSecurityChecks = true;
    02.User user = userManager.GetUser(identity.Name.ToString());
    03.Role role = roleManager.GetRole("GPAA");
    04.roleManager.RemoveUserFromRole(user, role);
    05.roleManager.SaveChanges();
    06.role = roleManager.GetRole("Member");
    07.password = user.GetPassword();
    08.roleManager.AddUserToRole(user, role);
    09.roleManager.SaveChanges();
    10.role = roleManager.GetRole("Member");
    11.isUserInRole = roleManager.IsUserInRole(user.Id, role.Id);
    And then re login the user 

    01.HttpContext.Current.Session["IsMember"] = true;
    02.SecurityManager.DeleteAuthCookies();
    03.SecurityManager.Logout();
    04.Credentials c = new Credentials();
    05. 
    06.c.UserName = identity.Name.ToString();
    07.c.Password = password;
    08.UserLoggingReason result = SecurityManager.AuthenticateUser(c);
    09.userManager.Provider.SuppressSecurityChecks = true;
    10.userManager.SaveChanges();
    11. 
    12.userManager.Provider.SuppressSecurityChecks = false;
    13.if (result == UserLoggingReason.Success)
    14.{
    15. 
    16.   
    17.    HttpContext.Current.Response.Write(jss.Serialize(true));
    18.    HttpContext.Current.Response.StatusCode = (int)HttpStatusCode.OK;
    19.    HttpContext.Current.Response.End();
    20. 
    21.}
     

    But the roles does not update with new role and i also cannot access the new roles pages

    but after i close my browser and log in again the user has new role any solution would be appreciated.

  2. Atanas Valchev
    Atanas Valchev avatar
    414 posts
    Registered:
    04 Jan 2016
    15 Sep 2014
    Link to this post
    Hi,

    After the new role is added, the user needs to log in again using the login form and the new role will be applied correctly.

    Regards,
    Atanas Valchev
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
2 posts, 0 answered