This commit is contained in:
2020-08-31 21:27:19 +00:00
parent 2dd3ee32ab
commit 5845440f1d
2 changed files with 17 additions and 12 deletions

View File

@@ -171,6 +171,9 @@ namespace AyaNova.Api.Controllers
ReportBiz biz = ReportBiz.GetBiz(ct, HttpContext);
if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType))
return StatusCode(403, new ApiNotAuthorizedResponse());
//extra check if they have rights to the type of object in question, this nips it in the bud before they even get to the fetch data stage later
if (!Authorized.HasReadFullRole(HttpContext.Items, ayType))
return StatusCode(403, new ApiNotAuthorizedResponse());
if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState));
var o = await biz.GetReportListAsync(ayType);

View File

@@ -170,8 +170,10 @@ namespace AyaNova.Biz
{
var rpts = await ct.Report.AsNoTracking().Where(z => z.ObjectType == ayType && z.Active == true).Select(z => new { id = z.Id, name = z.Name, roles = z.Roles }).ToListAsync();
var ret = new List<NameIdItem>();
foreach(var item in rpts){
if(CurrentUserRoles.HasAnyFlags(item.roles)){
foreach (var item in rpts)
{
if (CurrentUserRoles.HasAnyFlags(item.roles))
{
ret.Add(new NameIdItem() { Name = item.name, Id = item.id });
}
}