This commit is contained in:
@@ -55,8 +55,11 @@ namespace AyaNova.Api.Controllers
|
|||||||
public ActionResult GetLicenseInfo()
|
public ActionResult GetLicenseInfo()
|
||||||
{
|
{
|
||||||
if (serverState.IsClosed)
|
if (serverState.IsClosed)
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
{
|
||||||
|
//Exception for SuperUser account to handle licensing issues
|
||||||
|
if (UserIdFromContext.Id(HttpContext.Items) != 1)
|
||||||
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
|
}
|
||||||
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.License))
|
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.License))
|
||||||
{
|
{
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
@@ -95,9 +98,12 @@ namespace AyaNova.Api.Controllers
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> FetchLicense()
|
public async Task<IActionResult> FetchLicense()
|
||||||
{
|
{
|
||||||
if (serverState.IsClosed)
|
if (serverState.IsClosed)
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
{
|
||||||
|
//Exception for SuperUser account to handle licensing issues
|
||||||
|
if (UserIdFromContext.Id(HttpContext.Items) != 1)
|
||||||
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
|
}
|
||||||
if (!Authorized.HasCreateRole(HttpContext.Items, AyaType.License))
|
if (!Authorized.HasCreateRole(HttpContext.Items, AyaType.License))
|
||||||
{
|
{
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
@@ -152,8 +158,11 @@ namespace AyaNova.Api.Controllers
|
|||||||
public async Task<IActionResult> RequestTrial([FromBody] RequestTrial trialRequest)
|
public async Task<IActionResult> RequestTrial([FromBody] RequestTrial trialRequest)
|
||||||
{
|
{
|
||||||
if (serverState.IsClosed)
|
if (serverState.IsClosed)
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
{
|
||||||
|
//Exception for SuperUser account to handle licensing issues
|
||||||
|
if (UserIdFromContext.Id(HttpContext.Items) != 1)
|
||||||
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
|
}
|
||||||
if (!Authorized.HasCreateRole(HttpContext.Items, AyaType.License))
|
if (!Authorized.HasCreateRole(HttpContext.Items, AyaType.License))
|
||||||
{
|
{
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
@@ -201,9 +210,12 @@ namespace AyaNova.Api.Controllers
|
|||||||
[HttpPost("permanently-erase-all-data")]
|
[HttpPost("permanently-erase-all-data")]
|
||||||
public async Task<IActionResult> RemoveAllData([FromBody] string acceptCode)
|
public async Task<IActionResult> RemoveAllData([FromBody] string acceptCode)
|
||||||
{
|
{
|
||||||
if (serverState.IsClosed)
|
if (serverState.IsClosed)
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
{
|
||||||
|
//Exception for SuperUser account to handle licensing issues
|
||||||
|
if (UserIdFromContext.Id(HttpContext.Items) != 1)
|
||||||
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
|
}
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
|
|
||||||
|
|||||||
@@ -157,7 +157,8 @@ namespace AyaNova.Core
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
//TEST
|
||||||
|
// return LicenseStatus.ExpiredPurchased;
|
||||||
if (string.IsNullOrWhiteSpace(RegisteredTo) || RegisteredTo == UNLICENSED_TOKEN)
|
if (string.IsNullOrWhiteSpace(RegisteredTo) || RegisteredTo == UNLICENSED_TOKEN)
|
||||||
return LicenseStatus.NONE;
|
return LicenseStatus.NONE;
|
||||||
if (RegisteredTo == REVOKED_TOKEN)
|
if (RegisteredTo == REVOKED_TOKEN)
|
||||||
@@ -455,7 +456,7 @@ namespace AyaNova.Core
|
|||||||
{
|
{
|
||||||
return "ok";
|
return "ok";
|
||||||
}
|
}
|
||||||
else return res.Content.ToString();
|
else return $"E1020 - Error requesting trial license key: \"{res.ReasonPhrase}\"";
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user