This commit is contained in:
@@ -25,7 +25,7 @@ todo: FRESH PURCHASE ONBOARD
|
|||||||
TODO: auth route if not licensed at all (not merely expired, but non-existent) then only manager account can login, no one else
|
TODO: auth route if not licensed at all (not merely expired, but non-existent) then only manager account can login, no one else
|
||||||
(because there could be other users somehow but no license)
|
(because there could be other users somehow but no license)
|
||||||
|
|
||||||
todo: notify/hello route should no longer return false for trial true for not but instead:
|
todo: client global biz settings route should no longer return false for trial true for not but instead:
|
||||||
Return a license state enumeration value
|
Return a license state enumeration value
|
||||||
0 = No license at all of any kind
|
0 = No license at all of any kind
|
||||||
1 = trial license key
|
1 = trial license key
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
//so the only real barrier here would be a completely closed api
|
//so the only real barrier here would be a completely closed api
|
||||||
|
|
||||||
|
|
||||||
if (serverState.IsClosed && AyaNova.Core.License.ActiveKey.IsLicensed)
|
if (serverState.IsClosed && AyaNova.Core.License.ActiveKey.KeyDoesNotNeedAttention)
|
||||||
{
|
{
|
||||||
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,9 +46,8 @@ namespace AyaNova.Api.Controllers
|
|||||||
{
|
{
|
||||||
if (serverState.IsClosed)
|
if (serverState.IsClosed)
|
||||||
{
|
{
|
||||||
//Exception for manager account to handle licensing issues
|
|
||||||
if (UserIdFromContext.Id(HttpContext.Items) != 1)
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Instantiate the business object handler
|
//Instantiate the business object handler
|
||||||
@@ -102,7 +101,11 @@ namespace AyaNova.Api.Controllers
|
|||||||
public ActionResult GetClientGlobalBizSettings()
|
public ActionResult GetClientGlobalBizSettings()
|
||||||
{
|
{
|
||||||
if (serverState.IsClosed)
|
if (serverState.IsClosed)
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
{
|
||||||
|
//Exception for manager account to handle licensing issues
|
||||||
|
if (UserIdFromContext.Id(HttpContext.Items) != 1)
|
||||||
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
|
}
|
||||||
|
|
||||||
//Instantiate the business object handler
|
//Instantiate the business object handler
|
||||||
// GlobalBizSettingsBiz biz = GlobalBizSettingsBiz.GetBiz(ct, HttpContext);
|
// GlobalBizSettingsBiz biz = GlobalBizSettingsBiz.GetBiz(ct, HttpContext);
|
||||||
@@ -118,10 +121,23 @@ namespace AyaNova.Api.Controllers
|
|||||||
// if (o == null)
|
// if (o == null)
|
||||||
// return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
// return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Return a license state enumeration value
|
||||||
|
// 0 = No license at all of any kind
|
||||||
|
// 1 = trial license key
|
||||||
|
// 2 = purchased license key
|
||||||
|
// 3 = purchased but expired key (license itself is expired, not the maintenance, that's seperate)
|
||||||
|
// Note: this has nothing to do with whether there is an active license or not, merely that it's of a type
|
||||||
|
// this is so client can display appropriate UI
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//new object with only relevant items in it
|
//new object with only relevant items in it
|
||||||
var ret = new
|
var ret = new
|
||||||
{
|
{
|
||||||
SearchCaseSensitiveOnly = AyaNova.Util.ServerGlobalBizSettings.SearchCaseSensitiveOnly
|
SearchCaseSensitiveOnly = AyaNova.Util.ServerGlobalBizSettings.SearchCaseSensitiveOnly,
|
||||||
|
LicenseState = AyaNova.Core.License.ActiveKey.Status
|
||||||
};
|
};
|
||||||
|
|
||||||
return Ok(ApiOkResponse.Response(ret));
|
return Ok(ApiOkResponse.Response(ret));
|
||||||
|
|||||||
@@ -43,10 +43,10 @@ namespace AyaNova.Api.Controllers
|
|||||||
[HttpGet("hello")]
|
[HttpGet("hello")]
|
||||||
public ActionResult GetPreLoginPing()
|
public ActionResult GetPreLoginPing()
|
||||||
{
|
{
|
||||||
//note: this route is called by the client as the first action so it also acts like a ping to see if the server is up as well
|
//note: this route is called by the client to determine if it should display trial login ui
|
||||||
// if (serverState.IsClosed)
|
//and to see if the server is contactable
|
||||||
// return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
if (serverState.IsClosed)
|
||||||
//todo: check this route for dos attack potential??
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
return Ok(ApiOkResponse.Response(!AyaNova.Core.License.ActiveKey.TrialLicense));
|
return Ok(ApiOkResponse.Response(!AyaNova.Core.License.ActiveKey.TrialLicense));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,9 +65,9 @@ namespace AyaNova.Api.Controllers
|
|||||||
return Ok(ApiOkResponse.Response(69));
|
return Ok(ApiOkResponse.Response(69));
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: See new count case for gist of it
|
//TODO: See new count case for gist of it
|
||||||
//todo: see the core-notification.txt spec doc for details and
|
//todo: see the core-notification.txt spec doc for details and
|
||||||
//todo: see seemingly countless Notification related cases for details :)
|
//todo: see seemingly countless Notification related cases for details :)
|
||||||
|
|
||||||
//------------
|
//------------
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ namespace AyaNova.Core
|
|||||||
// private const string LICENSE_SERVER_URL = "https://rockfish.ayanova.com/";
|
// private const string LICENSE_SERVER_URL = "https://rockfish.ayanova.com/";
|
||||||
private const string LICENSE_SERVER_URL = "http://localhost:3001/";
|
private const string LICENSE_SERVER_URL = "http://localhost:3001/";
|
||||||
|
|
||||||
|
//Unlicensed token
|
||||||
|
private const string UNLICENSED_TOKEN = "UNLICENSED";
|
||||||
|
|
||||||
//Scheduleable users
|
//Scheduleable users
|
||||||
private const string SERVICE_TECHS_FEATURE_NAME = "ServiceTechs";
|
private const string SERVICE_TECHS_FEATURE_NAME = "ServiceTechs";
|
||||||
|
|
||||||
@@ -70,10 +73,26 @@ namespace AyaNova.Core
|
|||||||
//DTO object for parsed key
|
//DTO object for parsed key
|
||||||
internal class AyaNovaLicenseKey
|
internal class AyaNovaLicenseKey
|
||||||
{
|
{
|
||||||
|
// Return a license state enumeration value
|
||||||
|
// 0 = No license at all of any kind
|
||||||
|
// 1 = trial license key
|
||||||
|
// 2 = purchased license key
|
||||||
|
// 3 = purchased but expired key (license itself is expired, not the maintenance, that's seperate)
|
||||||
|
// Note: this has nothing to do with whether there is an active license or not, merely that it's of a type
|
||||||
|
// this is so client can display appropriate UI
|
||||||
|
public enum LicenseStatus
|
||||||
|
{
|
||||||
|
NONE = 0,
|
||||||
|
ActiveTrial = 1,
|
||||||
|
ExpiredTrial = 2,
|
||||||
|
ActivePurchased = 3,
|
||||||
|
ExpiredPurchased = 4
|
||||||
|
}
|
||||||
|
|
||||||
public AyaNovaLicenseKey()
|
public AyaNovaLicenseKey()
|
||||||
{
|
{
|
||||||
Features = new List<LicenseFeature>();
|
Features = new List<LicenseFeature>();
|
||||||
RegisteredTo = "UNLICENSED";
|
RegisteredTo = UNLICENSED_TOKEN;
|
||||||
Id = RegisteredTo;
|
Id = RegisteredTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,9 +149,27 @@ namespace AyaNova.Core
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LicenseStatus Status
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(RegisteredTo) || RegisteredTo == UNLICENSED_TOKEN)
|
||||||
|
return LicenseStatus.NONE;
|
||||||
|
if (TrialLicense && !LicenseExpired)
|
||||||
|
return LicenseStatus.ActiveTrial;
|
||||||
|
if (TrialLicense && LicenseExpired)
|
||||||
|
return LicenseStatus.ExpiredTrial;
|
||||||
|
if (!TrialLicense && !LicenseExpired)
|
||||||
|
return LicenseStatus.ActivePurchased;
|
||||||
|
if (!TrialLicense && LicenseExpired)
|
||||||
|
return LicenseStatus.ExpiredPurchased;
|
||||||
|
throw new System.Exception("License::Status - unable to determine license status");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Has any kind of valid license that is active
|
//Has any kind of valid license that is active
|
||||||
//used for auth route checking to allow for fixing this issue
|
//used for auth route checking to allow for fixing this issue
|
||||||
public bool IsLicensed
|
public bool KeyDoesNotNeedAttention
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -141,6 +178,7 @@ namespace AyaNova.Core
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public bool IsEmpty
|
public bool IsEmpty
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -257,7 +295,7 @@ namespace AyaNova.Core
|
|||||||
|
|
||||||
if (ActiveKey.IsEmpty)
|
if (ActiveKey.IsEmpty)
|
||||||
{
|
{
|
||||||
sb.AppendLine("UNLICENSED");
|
sb.AppendLine(UNLICENSED_TOKEN);
|
||||||
sb.AppendLine($"DB ID: {DbId}");
|
sb.AppendLine($"DB ID: {DbId}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user