server state cleanup

This commit is contained in:
2020-04-05 23:02:18 +00:00
parent d3d2fe8c46
commit 4af7664dce
10 changed files with 59 additions and 127 deletions

View File

@@ -54,11 +54,8 @@ namespace AyaNova.Api.Controllers
[HttpGet()]
public ActionResult GetLicenseInfo()
{
//Open or opsOnly and user is opsadminfull or opsadminlimited
if (!serverState.IsOpenOrOpsOnly || (serverState.IsOpsOnly && !Authorized.HasAnyRole(HttpContext.Items, AuthorizationRoles.OpsAdminFull | AuthorizationRoles.OpsAdminLimited)))
{
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
}
if (serverState.IsClosed)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.License))
{
@@ -83,11 +80,8 @@ namespace AyaNova.Api.Controllers
[HttpPost]
public async Task<IActionResult> FetchLicense()
{
//Open or opsOnly and user is opsadminfull
if (!serverState.IsOpenOrOpsOnly || (serverState.IsOpsOnly && !Authorized.HasAnyRole(HttpContext.Items, AuthorizationRoles.OpsAdminFull)))
{
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
}
if (serverState.IsClosed)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
if (!Authorized.HasCreateRole(HttpContext.Items, AyaType.License))
{
@@ -142,12 +136,8 @@ namespace AyaNova.Api.Controllers
[HttpPost("trial")]
public async Task<IActionResult> RequestTrial([FromBody] dtoTrialRequestData requestData)
{
//Open or opsOnly and user is opsadminfull
if (!serverState.IsOpenOrOpsOnly || (serverState.IsOpsOnly && !Authorized.HasAnyRole(HttpContext.Items, AuthorizationRoles.OpsAdminFull)))
{
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
//return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
}
if (serverState.IsClosed)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
if (!Authorized.HasCreateRole(HttpContext.Items, AyaType.License))
{