This commit is contained in:
2021-07-30 18:09:36 +00:00
parent 72fc11b673
commit cb73283a87
4 changed files with 20 additions and 15 deletions

View File

@@ -56,6 +56,11 @@ namespace AyaNova.Api.Controllers
if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
//This route is ONLY available to users with full rights to Global object
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.Global))
{
return StatusCode(403, new ApiNotAuthorizedResponse());
}
// AyaTypeId attachToObject = null;
ApiUploadProcessor.ApiUploadedFilesResult uploadFormData = null;
@@ -67,7 +72,7 @@ namespace AyaNova.Api.Controllers
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, $"Expected a multipart request, but got {Request.ContentType}"));
//Save uploads to disk under temporary file names until we decide how to handle them
// uploadFormData = await ApiUploadProcessor.ProcessUploadAsync(HttpContext);xx
// uploadFormData = await ApiUploadProcessor.ProcessUploadAsync(HttpContext);xx
string UploadAType = string.Empty;
@@ -76,7 +81,7 @@ namespace AyaNova.Api.Controllers
string Notes = string.Empty;
List<UploadFileData> FileData = new List<UploadFileData>();
//Save uploads to disk under temporary file names until we decide how to handle them
//Save uploads to disk under temporary file names until we decide how to handle them
uploadFormData = await ApiUploadProcessor.ProcessUploadAsync(HttpContext);
if (!string.IsNullOrWhiteSpace(uploadFormData.Error))
{
@@ -114,7 +119,7 @@ namespace AyaNova.Api.Controllers
//Instantiate the business object handler
AyaType TheType = System.Enum.Parse<AyaType>(UploadAType, true);
log.LogDebug($"Instantiating biz object handler for {TheType}");
var biz = BizObjectFactory.GetBizObject(TheType, ct);
var biz = BizObjectFactory.GetBizObject(TheType, ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
if (!(biz is IImportAbleObject))
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, $"Import not supported for {TheType} objects"));