Ejemplo n.º 1
0
        public async Task <IActionResult> DeleteRoleClaim([FromBody] RoleClaimDto roleClaimDto)
        {
            var role = await _roleManager.FindByIdAsync(roleClaimDto.RoleId);

            if (role != null)
            {
                var roleclaims = await _roleManager.GetClaimsAsync(role);

                if (roleclaims.FirstOrDefault(p => p.Type == roleClaimDto.ClaimType && p.Value == roleClaimDto.ClaimValue) != null)
                {
                    var RemoveClaimResult = await _roleManager.RemoveClaimAsync(role, new Claim(roleClaimDto.ClaimType, roleClaimDto.ClaimValue));

                    if (RemoveClaimResult.Succeeded)
                    {
                        return(Ok());
                    }
                    else
                    {
                        return(BadRequest(RemoveClaimResult.Errors));
                    }
                }
                else
                {
                    return(BadRequest("声明不存在"));
                }
            }
            return(BadRequest("角色不存在"));
        }
Ejemplo n.º 2
0
        internal async Task <BaseResponse> AddRoleClaimAsync(RoleClaimDto roleClaimDto)
        {
            if (!isSupper)
            {
                return(Unauthorized);
            }

            return(await httpClient.PostWithJsonResultAsync("api/user/CreateRoleClaim", roleClaimDto.BuildHttpContent()));
        }
 public async Task <IdentityResult> AddRoleclaims([FromBody] RoleClaimDto roleClaim)
 {
     return(await _svc.CreateRoleClims(roleClaim.Role, string.Join(',', roleClaim.Claims)));
 }
Ejemplo n.º 4
0
 protected override void OnInitialized()
 {
     model = new RoleClaimDto {
         RoleId = RoleId
     };
 }
Ejemplo n.º 5
0
 internal Task <BaseResponse> DeleteRoleClaim(RoleClaimDto roleClaimDto)
 {
     return(httpClient.PostWithJsonResultAsync
                ($"api/user/DeleteRoleClaim", roleClaimDto.BuildHttpContent()));
 }