private bool VerifyRoles(string url, IList <string> roles) { var headers = new List <Header>(); PayloadResponseDto <IList <string> > response = null; if (this.HttpContextAccessor.HttpContext.Request.Headers.Keys.Contains("Authorization")) { response = RestfulUtility.Get <PayloadResponseDto <IList <string> > >(url, this.HttpContextAccessor.HttpContext.Request.Headers["Authorization"], headers); } else { response = RestfulUtility.Get <PayloadResponseDto <IList <string> > >(url, headers); } if (response != null) { return(response.Payload.Intersect(roles).Count() > 0); } else { return(false); } }
protected PayloadResponseDto <int> VerifyOwner(Guid resourceId, Func <int> successFunc) { var payloadResponseDto = new PayloadResponseDto <int>(); this.VerifyOwner(this.Repository, resourceId, () => { payloadResponseDto.Payload = successFunc(); }, () => { this.HttpContext.Response.StatusCode = 403; payloadResponseDto.IsSuccessful = false; payloadResponseDto.ErrorCode = "OWNER_403"; payloadResponseDto.ErrorMessage = "The owner is different!"; }); return(payloadResponseDto); }