Copied to clipboard

Flag this post as spam?

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


  • AnandBhopale 53 posts 170 karma points
    May 11, 2021 @ 11:44
    AnandBhopale
    0

    Unable to remove default role for BackOffice user

    Hi Experts,

    I am trying to set BackOffice login user either as administrator or editor (default) from my OnAutoLinking method

    externalSignInAutoLink.OnAutoLinking = (BackOfficeIdentityUser user, ExternalLoginInfo info) =>
            {
    
    
                var role = info.ExternalIdentity.FindFirst("http://schemas.microsoft.com/ws/2008/06/identity/claims/role");
    
    
                if(role.Value == "ContentDesigner")
                {
                    if (user.Roles.Count > 0)
    
                    {
    
                       user.Roles.Remove(new IdentityUserRole<string> { 
                            RoleId ="editor",
                            UserId = "-2147483648"
                        });
    
                    }
    
    
                    user.AddRole("Admininstrator");
                }
                else
                {
                    user.AddRole("Editor");
                }
    

    Any pointers on how to remove default role and assign administrator. Is above method correct ? or is better way to do it ?

Please Sign in or register to post replies

Write your reply to:

Draft