This commit is contained in:
2020-08-06 18:06:23 +00:00
parent 151c2fbb72
commit bedb64f9d5
3 changed files with 25 additions and 2 deletions

View File

@@ -179,7 +179,29 @@ namespace AyaNova.Api.Controllers
}
/// <summary>
/// Get FormKey from id of FormCustom
/// </summary>
/// <returns>A formKey string if id found</returns>
[HttpGet("form-key/{id}")]
public async Task<IActionResult> GetFormKeyFromId(long id)
{
if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.FormCustom))
return StatusCode(403, new ApiNotAuthorizedResponse());
if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState));
var fc = await ct.FormCustom.FirstOrDefaultAsync(z => z.Id == id);
if (fc == null)
{
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
}
return Ok(ApiOkResponse.Response(fc.FormKey));
}
//------------