End User License consent system added
This commit is contained in:
@@ -22,16 +22,16 @@ namespace AyaNova.Util
|
||||
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImportingAsync WHEN NEW TABLES ADDED!!!!
|
||||
private const int DESIRED_SCHEMA_LEVEL = 1;
|
||||
|
||||
internal const long EXPECTED_COLUMN_COUNT = 1324;
|
||||
internal const long EXPECTED_COLUMN_COUNT = 1325;
|
||||
internal const long EXPECTED_INDEX_COUNT = 153;
|
||||
internal const long EXPECTED_CHECK_CONSTRAINTS = 519;
|
||||
internal const long EXPECTED_CHECK_CONSTRAINTS = 520;
|
||||
internal const long EXPECTED_FOREIGN_KEY_CONSTRAINTS = 198;
|
||||
internal const long EXPECTED_VIEWS = 11;
|
||||
internal const long EXPECTED_ROUTINES = 2;
|
||||
|
||||
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImportingAsync WHEN NEW TABLES ADDED!!!!
|
||||
|
||||
///////////////////////////////////////// C1324:I153:CC519:FC198:V11:R2
|
||||
///////////////////////////////////////// C1325:I153:CC520:FC198:V11:R2
|
||||
|
||||
|
||||
|
||||
@@ -624,7 +624,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
||||
await AyaNova.Biz.PrimeData.PrimeSuperUserAccount(ct);
|
||||
|
||||
//Add user table
|
||||
await ExecQueryAsync("CREATE TABLE alicense (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, dbid TEXT, key TEXT NOT NULL)");
|
||||
await ExecQueryAsync("CREATE TABLE alicense (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, licenseagree BOOL NOT NULL, dbid TEXT, key TEXT NOT NULL)");
|
||||
|
||||
await ExecQueryAsync("CREATE TABLE afileattachment (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, "
|
||||
+ "attachtoobjectid BIGINT NOT NULL, attachtoatype INTEGER NOT NULL, "
|
||||
|
||||
@@ -73,6 +73,7 @@ namespace AyaNova.Core
|
||||
//The license dbid, separate from the server dbid
|
||||
private static string LicenseDbId { get; set; }
|
||||
|
||||
|
||||
#region license classes
|
||||
|
||||
//DTO object returned on license query
|
||||
@@ -184,6 +185,8 @@ namespace AyaNova.Core
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Has any kind of valid license that is active
|
||||
//used for auth route checking to allow for fixing this issue
|
||||
public bool KeyDoesNotNeedAttention
|
||||
@@ -257,6 +260,7 @@ namespace AyaNova.Core
|
||||
public List<LicenseFeature> Features { get; set; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -302,6 +306,9 @@ namespace AyaNova.Core
|
||||
//The database id value stored in the schema table
|
||||
internal static string ServerDbId { get; private set; }
|
||||
|
||||
internal static bool LicenseConsentRequired { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Fetch a summary of the license key for displaying to the end user
|
||||
/// </summary>
|
||||
@@ -443,10 +450,32 @@ namespace AyaNova.Core
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region EULA consent
|
||||
/// <summary>
|
||||
/// Set consent flag for license agreement
|
||||
/// </summary>
|
||||
internal static async Task FlagEULA(AyContext ct, ILogger log)
|
||||
{
|
||||
try
|
||||
{
|
||||
var CurrentInDbKeyRecord = await ct.License.OrderBy(z => z.Id).FirstOrDefaultAsync();
|
||||
if (CurrentInDbKeyRecord == null)
|
||||
throw new ApplicationException("E1020 - Can't update EULA agreement, no key record found");
|
||||
//Update current license
|
||||
CurrentInDbKeyRecord.LicenseAgree = true;
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var msg = "E1020 - Error during EULA agreement flagging";
|
||||
log.LogError(ex, msg);
|
||||
throw new ApplicationException(msg, ex);
|
||||
}
|
||||
LicenseConsentRequired = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Trial license request handling
|
||||
/// <summary>
|
||||
@@ -484,7 +513,7 @@ namespace AyaNova.Core
|
||||
#endregion trial license request handling
|
||||
|
||||
|
||||
#region License fetching and handling
|
||||
#region License fetching and handling
|
||||
|
||||
public class dtoFetchRequest
|
||||
{
|
||||
@@ -657,6 +686,7 @@ namespace AyaNova.Core
|
||||
ldb = new Models.License();
|
||||
ldb.DbId = ServerDbId;
|
||||
ldb.Key = "none";
|
||||
ldb.LicenseAgree = false;
|
||||
ct.License.Add(ldb);
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
@@ -666,6 +696,7 @@ namespace AyaNova.Core
|
||||
if (string.IsNullOrWhiteSpace(ldb.DbId))
|
||||
{
|
||||
ldb.DbId = ServerDbId;
|
||||
ldb.LicenseAgree = false;
|
||||
//Convert the no tracking record fetched above to tracking
|
||||
//this is required because a prior call to initialize before dumping the db would mean the license is still in memory in the context
|
||||
ct.Entry(ldb).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
|
||||
@@ -675,10 +706,13 @@ namespace AyaNova.Core
|
||||
//Get it early and set it here so that it can be displayed early to the user even if not licensed
|
||||
LicenseDbId = ldb.DbId;
|
||||
|
||||
//someone must agree to the license on first login from the client, this stores that
|
||||
LicenseConsentRequired = !ldb.LicenseAgree;
|
||||
|
||||
if (ldb.Key == "none")
|
||||
{
|
||||
var msg = "E1020 - License key not found in database, running in unlicensed mode";
|
||||
apiServerState.SetSystemLock(msg);
|
||||
apiServerState.SetSystemLock(msg);
|
||||
log.LogWarning(msg);
|
||||
return;
|
||||
}
|
||||
@@ -790,6 +824,8 @@ namespace AyaNova.Core
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region PARSE and Validate key
|
||||
|
||||
Reference in New Issue
Block a user