Exemplo n.º 1
0
 public async Task <IActionResult> GetActorClaims([FromRoute] int id)
 {
     if ((await _authorizationService.AuthorizeAsync(User, id, HttpContext.ScopeItems(ClaimScope.Group))).Succeeded ||
         (await _authorizationService.AuthorizeAsync(User, id, HttpContext.ScopeItems(ClaimScope.User))).Succeeded)
     {
         var claims         = _actorClaimCoreController.GetActorClaims(id);
         var claimsContract = claims.ToContractList();
         return(new ObjectResult(claimsContract));
     }
     return(Forbid());
 }
Exemplo n.º 2
0
 public async Task <IActionResult> Create([FromBody] RoleClaimRequest newRoleClaim)
 {
     if ((await _authorizationService.AuthorizeAsync(User, newRoleClaim.RoleId, HttpContext.ScopeItems(ClaimScope.Role))).Succeeded)
     {
         var role = _roleController.GetById(newRoleClaim.RoleId.Value);
         if (!role.Default)
         {
             var claimScope = _claimController.Get(newRoleClaim.ClaimId.Value).ClaimScope;
             if (role.ClaimScope == claimScope)
             {
                 var claims = _actorClaimController.GetActorClaims(int.Parse(User.Identity.Name)).Select(c => c.ClaimId);
                 if (claims.Contains(newRoleClaim.ClaimId.Value))
                 {
                     var roleClaim = newRoleClaim.ToModel();
                     _roleClaimCoreController.Create(roleClaim);
                     var roleContract = roleClaim.ToContract();
                     return(new ObjectResult(roleContract));
                 }
             }
         }
     }
     return(Forbid());
 }