Beispiel #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("角色不存在"));
        }
        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)));
 }
 protected override void OnInitialized()
 {
     model = new RoleClaimDto {
         RoleId = RoleId
     };
 }
 internal Task <BaseResponse> DeleteRoleClaim(RoleClaimDto roleClaimDto)
 {
     return(httpClient.PostWithJsonResultAsync
                ($"api/user/DeleteRoleClaim", roleClaimDto.BuildHttpContent()));
 }