server state cleanup

This commit is contained in:
2020-04-05 21:35:42 +00:00
parent e367b4b132
commit 8443c7c5bf
15 changed files with 116 additions and 101 deletions

View File

@@ -68,10 +68,9 @@ namespace AyaNova.Api.Controllers
{
//a bit different as ops users can still login if the state is opsonly
//so the only real barrier here would be a completely closed api
if (!serverState.IsOpenOrOpsOnly)
{
if (serverState.IsClosed)
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
}
int nFailedAuthDelay = 3000;//should be just long enough to make brute force a hassle but short enough to not annoy people who just mistyped their creds to login
@@ -174,7 +173,7 @@ namespace AyaNova.Api.Controllers
!u.Roles.HasFlag(Biz.AuthorizationRoles.OpsAdminFull) &&
!u.Roles.HasFlag(Biz.AuthorizationRoles.OpsAdminLimited))
{
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
}
@@ -243,9 +242,7 @@ namespace AyaNova.Api.Controllers
public async Task<IActionResult> ChangePassword([FromBody] AuthController.ChangePasswordParam changecreds)
{
if (!serverState.IsOpen)
{
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
}
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
if (!ModelState.IsValid)
{