This commit is contained in:
@@ -56,7 +56,7 @@ namespace AyaNova.Api.Controllers
|
||||
[HttpGet("{formkey}")]
|
||||
public async Task<IActionResult> GetFormCustom([FromRoute] string formkey, [FromQuery] uint? concurrency)
|
||||
{
|
||||
if (serverState.IsClosed)
|
||||
if (serverState.IsClosed && UserIdFromContext.Id(HttpContext.Items) != 1)//bypass for superuser to fix fundamental problems
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
|
||||
//Instantiate the business object handler
|
||||
@@ -104,7 +104,7 @@ namespace AyaNova.Api.Controllers
|
||||
[HttpGet("availablecustomtypes")]
|
||||
public ActionResult GetAvailableCustomTypes()
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
if (!serverState.IsOpen && UserIdFromContext.Id(HttpContext.Items) != 1)//bypass for superuser to fix fundamental problems
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
|
||||
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.FormCustom))
|
||||
@@ -124,7 +124,7 @@ namespace AyaNova.Api.Controllers
|
||||
[HttpGet("availablecustomizableformkeys")]
|
||||
public ActionResult GetAvailableCustomizableFormKeys()
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
if (!serverState.IsOpen && UserIdFromContext.Id(HttpContext.Items) != 1)//bypass for superuser to fix fundamental problems
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
|
||||
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.FormCustom))
|
||||
@@ -147,7 +147,7 @@ namespace AyaNova.Api.Controllers
|
||||
[HttpPut("{formkey}")]
|
||||
public async Task<IActionResult> PutFormCustom([FromRoute] string formkey, [FromBody] FormCustom inObj)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
if (!serverState.IsOpen && UserIdFromContext.Id(HttpContext.Items) != 1)//bypass for superuser to fix fundamental problems
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
@@ -186,7 +186,7 @@ namespace AyaNova.Api.Controllers
|
||||
[HttpGet("form-key/{id}")]
|
||||
public async Task<IActionResult> GetFormKeyFromId(long id)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
if (!serverState.IsOpen && UserIdFromContext.Id(HttpContext.Items) != 1)//bypass for superuser to fix fundamental problems
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
|
||||
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.FormCustom))
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace AyaNova.Api.Controllers
|
||||
[HttpGet("{id}")]
|
||||
public async Task<IActionResult> GetUserOptions([FromRoute] long id)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
if (!serverState.IsOpen && UserIdFromContext.Id(HttpContext.Items) != 1)//bypass for superuser to fix fundamental problems
|
||||
{
|
||||
//Exception for SuperUser account to handle licensing issues
|
||||
if (UserIdFromContext.Id(HttpContext.Items) != 1)
|
||||
@@ -137,7 +137,7 @@ namespace AyaNova.Api.Controllers
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> PutUserOptions([FromRoute] long id, [FromBody] UserOptions inObj)
|
||||
{
|
||||
if (serverState.IsClosed)
|
||||
if (serverState.IsClosed && UserIdFromContext.Id(HttpContext.Items) != 1)//bypass for superuser to fix fundamental problems
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
|
||||
@@ -724,7 +724,19 @@ namespace AyaNova.Biz
|
||||
|
||||
//Remove the object
|
||||
ct.User.Remove(dbObject);
|
||||
try
|
||||
{
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
catch (Microsoft.EntityFrameworkCore.DbUpdateException)
|
||||
{
|
||||
//SPECIAL EXCEPTION
|
||||
//seeded data isn't always attributed to the user who would normally have created data so
|
||||
//this could fail due to referential integrity as they wouldn't be in the event log check above
|
||||
//easiest workaround to avoid having to check a whole host of items is to just check if this fails due to ref.integrity and return sane message
|
||||
AddError(ApiErrorCode.INVALID_OPERATION, "generalerror", await Translate("ErrorDBForeignKeyViolation"));
|
||||
return false;
|
||||
}
|
||||
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
|
||||
Reference in New Issue
Block a user