From 0016204582b6d3a2775dc0e933e10891586f9d51 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 23 Aug 2022 16:56:20 +0000 Subject: [PATCH] --- server/AyaNova/Controllers/AuthController.cs | 2 +- server/AyaNova/Startup.cs | 9 ++++++--- server/AyaNova/generator/CoreJobSweeper.cs | 10 +++------- server/AyaNova/util/License.cs | 16 ++++++++++------ 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/server/AyaNova/Controllers/AuthController.cs b/server/AyaNova/Controllers/AuthController.cs index ee7463dc..5ab96e85 100644 --- a/server/AyaNova/Controllers/AuthController.cs +++ b/server/AyaNova/Controllers/AuthController.cs @@ -222,7 +222,7 @@ namespace AyaNova.Api.Controllers } else { - if (serverState.Reason.Contains("E1020 - Active count exceeded capacity")) + if (serverState.Reason.Contains(AyaNova.Core.License.SERVER_STATE_LOCKOUT_DUE_TO_LICENSE_EXCEEDED_CAPACITY_ERROR)) { licenseLockout = true;//this could be an expired license or user count exceeded capacity so flag to client on login so superuser can fix it } diff --git a/server/AyaNova/Startup.cs b/server/AyaNova/Startup.cs index 3ae32f2a..bb474d85 100644 --- a/server/AyaNova/Startup.cs +++ b/server/AyaNova/Startup.cs @@ -699,9 +699,12 @@ namespace AyaNova ServerBootConfig.BOOT_DIAGNOSTIC_INFO.Add("DB Schema version", AyaNova.Util.AySchema.currentSchema.ToString()); - //Log the active user count so it's in the log record - _newLog.LogInformation($"Active techs - {UserBiz.ActiveTechUserCountAsync().Result}"); -LOGHERE + //Log the active user counts so it's in the log record + //I'm doing all three even though some not relevant in certain scenarios in case of user switching between subscription/perpetual as another source of information + _newLog.LogInformation($"Active tech Users - {UserBiz.ActiveTechUserCountAsync().Result}"); + _newLog.LogInformation($"Active Customer contact Users - {UserBiz.ActiveCustomerContactUserCountAsync().Result}"); + _newLog.LogInformation($"Active internal staff Users - {UserBiz.ActiveInternalUserCountAsync().Result}"); + //Log the license info so it's on the record _newLog.LogInformation($"License - [{AyaNova.Core.License.LicenseInfoLogFormat}]"); diff --git a/server/AyaNova/generator/CoreJobSweeper.cs b/server/AyaNova/generator/CoreJobSweeper.cs index c7d3efe6..6b6a0479 100644 --- a/server/AyaNova/generator/CoreJobSweeper.cs +++ b/server/AyaNova/generator/CoreJobSweeper.cs @@ -59,13 +59,9 @@ namespace AyaNova.Biz //Stealthy check of user count exceeded if (await UserBiz.ActiveTechUserCountAsync() > AyaNova.Core.License.ActiveKey.ActiveTechsCount) { - HERE - //WARNING: DO not change the text of this message without also - //updating the authcontroller ReturnUserCredsOnSuccessfulAuthentication licenselockout check code - //it must match - var msg = $"E1020 - Active count exceeded capacity"; - AyaNova.Util.ServiceProviderProvider.ServerState.SetSystemLock(msg); - log.LogCritical(msg); + //Warning: magic string, do not change this, triggers special login procedures to fix license issue + AyaNova.Util.ServiceProviderProvider.ServerState.SetSystemLock(AyaNova.Core.License.SERVER_STATE_LOCKOUT_DUE_TO_LICENSE_EXCEEDED_CAPACITY_ERROR); + log.LogCritical(AyaNova.Core.License.SERVER_STATE_LOCKOUT_DUE_TO_LICENSE_EXCEEDED_CAPACITY_ERROR); return; } diff --git a/server/AyaNova/util/License.cs b/server/AyaNova/util/License.cs index e3674b8a..1d1e87a9 100644 --- a/server/AyaNova/util/License.cs +++ b/server/AyaNova/util/License.cs @@ -53,6 +53,9 @@ namespace AyaNova.Core internal const string LICENSE_MISMATCH_TO_BUILD_ERROR = "E1020 - Not licensed for this version of AyaNova. Fix: revert to previous version used or contact technical support for options"; + //Warning: magic string, do not change this, triggers special login procedures to fix license issue + internal const string SERVER_STATE_LOCKOUT_DUE_TO_LICENSE_EXCEEDED_CAPACITY_ERROR = "E1020 - Active count exceeded capacity"; + //Unlicensed token private const string UNLICENSED_TOKEN = "UNLICENSED"; @@ -774,11 +777,13 @@ namespace AyaNova.Core return; } + + //Has someone been trying funny business with the active techs in the db? #if (SUBSCRIPTION_BUILD) if (await AyaNova.Biz.UserBiz.ActiveInternalUserCountAsync() > _ActiveLicense.ActiveInternalUsersCount) { - var msg = $"E1020 - Active internal staff User count exceeded licensed capacity"; + var msg = $"{SERVER_STATE_LOCKOUT_DUE_TO_LICENSE_EXCEEDED_CAPACITY_ERROR} (internal staff User count)"; apiServerState.SetSystemLock(msg); log.LogCritical(msg); return; @@ -787,7 +792,7 @@ namespace AyaNova.Core if (await AyaNova.Biz.UserBiz.ActiveCustomerContactUserCountAsync() > _ActiveLicense.ActiveCustomerContactUsersCount) { - var msg = $"E1020 - Active Customer Contact User count exceeded licensed capacity"; + var msg = $"{SERVER_STATE_LOCKOUT_DUE_TO_LICENSE_EXCEEDED_CAPACITY_ERROR} (Customer Contact User count)"; apiServerState.SetSystemLock(msg); log.LogCritical(msg); return; @@ -797,13 +802,12 @@ namespace AyaNova.Core #else if (await AyaNova.Biz.UserBiz.ActiveTechUserCountAsync() > _ActiveLicense.ActiveTechsCount) { - var msg = $"E1020 - Active count exceeded capacity"; - apiServerState.SetSystemLock(msg); - log.LogCritical(msg); + apiServerState.SetSystemLock(SERVER_STATE_LOCKOUT_DUE_TO_LICENSE_EXCEEDED_CAPACITY_ERROR); + log.LogCritical(SERVER_STATE_LOCKOUT_DUE_TO_LICENSE_EXCEEDED_CAPACITY_ERROR); return; } #endif - //Has someone been trying funny business with the active techs in the db? + //Key is ok, might not have been on first boot so check and clear if locked