Update to properly handle revoke licenses

This commit is contained in:
2022-08-29 15:26:30 +00:00
parent 9b7508afe3
commit da4255a531
3 changed files with 36 additions and 29 deletions

2
.vscode/launch.json vendored
View File

@@ -121,7 +121,7 @@
"AYANOVA_USE_URLS": "http://*:7575;", "AYANOVA_USE_URLS": "http://*:7575;",
//"AYANOVA_PERMANENTLY_ERASE_DATABASE":"true", //"AYANOVA_PERMANENTLY_ERASE_DATABASE":"true",
//"AYANOVA_REMOVE_LICENSE_FROM_DB":"true", //"AYANOVA_REMOVE_LICENSE_FROM_DB":"true",
"AYANOVA_SERVER_TEST_MODE": "true", //"AYANOVA_SERVER_TEST_MODE": "true",
"AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-8", "AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-8",
"AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small", "AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small",
"AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_14\\bin" "AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_14\\bin"

View File

@@ -34,12 +34,14 @@ WIP >>>>>>>>>>>>>
Status: Test recent change to customer login license check making new user or setting to active or setting to allowlogin Status:
Also in between times fixup the additional fields in product pages for sale see item in parallel work section below (and see if can change price on subscription or do I need to make a new one?) Also in between times fixup the additional fields in product pages for sale see item in parallel work section below (and see if can change price on subscription or do I need to make a new one?)
todo: Test how to revoke a license, I'm wondering if new code at license.cs is now preventing installing the revoke license todo: Test how to revoke a license, I'm wondering if new code at license.cs is now preventing installing the revoke license
todo: expired license does it stop notifying and jobs??
I think all jobs should stop and not be processed except for the license fetching job
NOTE: NOT RELEASABLE, MANUAL NEEDS TO BE UPDATED FIRST THEN CAN REBUILD AND POST NOTE: NOT RELEASABLE, MANUAL NEEDS TO BE UPDATED FIRST THEN CAN REBUILD AND POST

View File

@@ -901,6 +901,10 @@ namespace AyaNova.Core
throw new ApplicationException("E1020 - Can't install a trial key into a non empty AyaNova database. Erase the database first."); throw new ApplicationException("E1020 - Can't install a trial key into a non empty AyaNova database. Erase the database first.");
} }
//Only check quantities if it's not a revoke token which should always pass through
if (ParsedNewKey.RegisteredTo != REVOKED_TOKEN)
{
#if (SUBSCRIPTION_BUILD) #if (SUBSCRIPTION_BUILD)
//SUBSCRIPTION USER COUNTS - new license causes exceeding counts? //SUBSCRIPTION USER COUNTS - new license causes exceeding counts?
@@ -928,18 +932,18 @@ namespace AyaNova.Core
throw new ApplicationException(err); throw new ApplicationException(err);
#else #else
//PERPETUAL, vet the TECHCOUNT - new license causes exceeding count? //PERPETUAL, vet the TECHCOUNT - new license causes exceeding count?
long NewTechCount = ParsedNewKey.ActiveTechsCount; long NewTechCount = ParsedNewKey.ActiveTechsCount;
if (await AyaNova.Biz.UserBiz.ActiveTechUserCountAsync() > NewTechCount)
{
//attempt to set enough of the eldest last login techs to inactive
await AyaNova.Biz.UserBiz.DeActivateExcessiveTechs(NewTechCount, log);
if (await AyaNova.Biz.UserBiz.ActiveTechUserCountAsync() > NewTechCount) if (await AyaNova.Biz.UserBiz.ActiveTechUserCountAsync() > NewTechCount)
throw new ApplicationException("E1020 - Can't install key, too many active techs and / or subcontractors in database. Deactivate enough to install key."); {
} //attempt to set enough of the eldest last login techs to inactive
#endif await AyaNova.Biz.UserBiz.DeActivateExcessiveTechs(NewTechCount, log);
if (await AyaNova.Biz.UserBiz.ActiveTechUserCountAsync() > NewTechCount)
throw new ApplicationException("E1020 - Can't install key, too many active techs and / or subcontractors in database. Deactivate enough to install key.");
}
#endif
}
//Update current license //Update current license
@@ -1063,17 +1067,18 @@ EQIDAQAB
#endregion get values #endregion get values
if (key.RegisteredTo != REVOKED_TOKEN)
//Check if attempting to use a build of AyaNova that is newer than maintenance subscription expiry
if (MExBB(Util.FileUtil.GetLinkerTimestampUtc(System.Reflection.Assembly.GetExecutingAssembly()), key))
{ {
Console.WriteLine(LICENSE_MISMATCH_TO_BUILD_ERROR); //Check if attempting to use a build of AyaNova that is newer than maintenance subscription expiry
log.LogError("E1020 - build too new for license"); if (MExBB(Util.FileUtil.GetLinkerTimestampUtc(System.Reflection.Assembly.GetExecutingAssembly()), key))
//NOTE: LICENSE_MISMATCH_TO_BUILD_ERROR matched for in startup.cs DO NOT change this without fixing the side effects {
throw new ApplicationException(LICENSE_MISMATCH_TO_BUILD_ERROR); Console.WriteLine(LICENSE_MISMATCH_TO_BUILD_ERROR);
} log.LogError("E1020 - build too new for license");
//NOTE: LICENSE_MISMATCH_TO_BUILD_ERROR matched for in startup.cs DO NOT change this without fixing the side effects
throw new ApplicationException(LICENSE_MISMATCH_TO_BUILD_ERROR);
}
//Subscription licenses only for subscription builds and Perpetual licenses only for Perpetual builds //Subscription licenses only for subscription builds and Perpetual licenses only for Perpetual builds
#if (SUBSCRIPTION_BUILD) #if (SUBSCRIPTION_BUILD)
if(key.Perpetual){ if(key.Perpetual){
Console.WriteLine(LICENSE_MISMATCH_TO_BUILD_ERROR); Console.WriteLine(LICENSE_MISMATCH_TO_BUILD_ERROR);
@@ -1082,16 +1087,16 @@ EQIDAQAB
throw new ApplicationException(LICENSE_MISMATCH_TO_BUILD_ERROR); throw new ApplicationException(LICENSE_MISMATCH_TO_BUILD_ERROR);
} }
#else #else
if (!key.Perpetual) if (!key.Perpetual)
{ {
Console.WriteLine(LICENSE_MISMATCH_TO_BUILD_ERROR); Console.WriteLine(LICENSE_MISMATCH_TO_BUILD_ERROR);
log.LogError("E1020 - perpetual build but subscription key"); log.LogError("E1020 - perpetual build but subscription key");
//NOTE: LICENSE_MISMATCH_TO_BUILD_ERROR bit below is checked for in startup.cs DO NOT remove this without fixing the side effects //NOTE: LICENSE_MISMATCH_TO_BUILD_ERROR bit below is checked for in startup.cs DO NOT remove this without fixing the side effects
throw new ApplicationException(LICENSE_MISMATCH_TO_BUILD_ERROR); throw new ApplicationException(LICENSE_MISMATCH_TO_BUILD_ERROR);
} }
#endif #endif
}
//All is well return key //All is well return key
return key; return key;