This commit is contained in:
@@ -77,47 +77,23 @@ namespace AyaNova.Api.Controllers
|
|||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
|
|
||||||
|
|
||||||
var PickList = PickListFactory.GetAyaPickList(ayaType);
|
var PickList = PickListFactory.GetAyaPickList(ayaType);
|
||||||
|
|
||||||
//was the name not found as a pick list?
|
//was the name not found as a pick list?
|
||||||
if (PickList == null)
|
if (PickList == null)
|
||||||
{
|
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||||
//not a user error so no need to localize
|
|
||||||
AddError(ApiErrorCode.NOT_FOUND, "ayaType", $"PickList for type \"{ayaType}\" specified does not exist");
|
|
||||||
return null;
|
|
||||||
|
|
||||||
}
|
//check rights
|
||||||
|
if (!Authorized.HasAnyRole(HttpContext.Items, PickList.AllowedRoles))
|
||||||
//check rights
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
|
|
||||||
if (!userRoles.HasAnyFlags(PickList.AllowedRoles))
|
|
||||||
{
|
|
||||||
AddError(ApiErrorCode.NOT_AUTHORIZED, "ayaType");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
throw new System.UnauthorizedAccessException("User roles insufficient for this datalist");
|
|
||||||
|
|
||||||
|
|
||||||
// var UserRoles = UserRolesFromContext.Roles(HttpContext.Items);
|
|
||||||
|
|
||||||
var o = await biz.GetPickListAsync(PickList, query, inactive);
|
var o = await biz.GetPickListAsync(PickList, query, inactive);
|
||||||
|
|
||||||
/* this is how a bad validation is handled in a widget post
|
|
||||||
//we need to validate the query and return an explanation if it's bad so user doesn't get confused and think theya re doing the right thing but not getting results anyway
|
|
||||||
//Create and validate
|
|
||||||
Widget o = await biz.CreateAsync(inObj);
|
|
||||||
if (o == null)
|
if (o == null)
|
||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||||
else
|
else
|
||||||
return CreatedAtAction(nameof(WidgetController.GetWidget), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
|
return Ok(ApiOkResponse.Response(o, true));
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (o == null)
|
|
||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
|
||||||
|
|
||||||
|
|
||||||
return Ok(ApiOkResponse.Response(o, true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user