This commit is contained in:
@@ -42,10 +42,10 @@ namespace AyaNova.Api.ControllerHelpers
|
||||
internal void SetSystemLock(string reason)
|
||||
{
|
||||
//Lock down the server for license related issue
|
||||
//Only Manager account (id=1) can login or do anything, treats as if server was set to closed even if they change it to open
|
||||
//Only SuperUser account (id=1) can login or do anything, treats as if server was set to closed even if they change it to open
|
||||
//only way to reset it is to fetch a valid license
|
||||
//
|
||||
var msg=$"{reason}\r\nOnly *the* Manager account can login to make changes";
|
||||
var msg=$"{reason}\r\nOnly *the* SuperUser account can login to make changes";
|
||||
SetState(ServerState.OpsOnly, msg);
|
||||
SYSTEM_LOCK = true;
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace AyaNova.Api.Controllers
|
||||
return Ok(ApiOkResponse.Response(new
|
||||
{
|
||||
token = TestToken,
|
||||
name = "Manager Account - TESTING",
|
||||
name = "SuperUser Account - TESTING",
|
||||
roles = "0"
|
||||
}));
|
||||
|
||||
@@ -168,10 +168,10 @@ namespace AyaNova.Api.Controllers
|
||||
|
||||
//check if server closed
|
||||
//if it is it means we got here only because there is no license
|
||||
//and only *the* manager account can login now
|
||||
//and only *the* SuperUser account can login now
|
||||
if(serverState.IsClosed){
|
||||
//if not manager account then boot closed
|
||||
//manager account is always ID 1
|
||||
//if not SuperUser account then boot closed
|
||||
//SuperUser account is always ID 1
|
||||
if(u.Id!=1){
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace AyaNova.Api.Controllers
|
||||
{
|
||||
if (serverState.IsClosed)
|
||||
{
|
||||
//Exception for manager account to handle licensing issues
|
||||
//Exception for SuperUser account to handle licensing issues
|
||||
if (UserIdFromContext.Id(HttpContext.Items) != 1)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
}
|
||||
|
||||
@@ -192,9 +192,9 @@ namespace AyaNova.Api.Controllers
|
||||
/// Posting to this route causes AyaNova completely erase all data in it's database and erase all attachment files
|
||||
/// returning the database to an empty state
|
||||
///
|
||||
/// The only items retained are the Manager account and the license key
|
||||
/// The only items retained are the SuperUser account and the license key
|
||||
///
|
||||
/// (Only *the* Manager account can use this route)
|
||||
/// (Only *the* SuperUser account can use this route)
|
||||
/// </summary>
|
||||
/// <param name="acceptCode">Must be "I understand"</param>
|
||||
/// <returns>HTTP 204 No Content result code on success or fail code with explanation</returns>
|
||||
@@ -209,7 +209,7 @@ namespace AyaNova.Api.Controllers
|
||||
|
||||
long UserId = UserIdFromContext.Id(HttpContext.Items);
|
||||
|
||||
//Manager only and must have accept code
|
||||
//SuperUser only and must have accept code
|
||||
if (UserId != 1 || string.IsNullOrWhiteSpace(acceptCode) || acceptCode.ToLowerInvariant() != "i understand")
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace AyaNova.Api.Controllers
|
||||
{
|
||||
if (serverState.IsClosed)
|
||||
{
|
||||
//Exception for manager account to handle licensing issues
|
||||
//Exception for SuperUser account to handle licensing issues
|
||||
if (UserIdFromContext.Id(HttpContext.Items) != 1)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace AyaNova.Api.Controllers
|
||||
{
|
||||
if (serverState.IsClosed)
|
||||
{
|
||||
//Exception for manager account to handle licensing issues
|
||||
//Exception for SuperUser account to handle licensing issues
|
||||
if (UserIdFromContext.Id(HttpContext.Items) != 1)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
}
|
||||
|
||||
@@ -9,22 +9,22 @@ using AyaNova.Models;
|
||||
namespace AyaNova.Biz
|
||||
{
|
||||
|
||||
//Prime the database with initial, minimum required data to boot and do things (manager account, translations)
|
||||
//Prime the database with initial, minimum required data to boot and do things (SuperUser account, translations)
|
||||
public static class PrimeData
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Prime the database with manager account
|
||||
/// Prime the database with SuperUser account
|
||||
/// </summary>
|
||||
public static async Task PrimeManagerAccount(AyContext ct)
|
||||
public static async Task PrimeSuperUserAccount(AyContext ct)
|
||||
{
|
||||
//get a db and logger
|
||||
//ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("PrimeData");
|
||||
User u = new User();
|
||||
u.Active = true;
|
||||
u.Name = "AyaNova Administrator";
|
||||
u.Name = "AyaNova SuperUser";
|
||||
u.Salt = Hasher.GenerateSalt();
|
||||
u.Login = "manager";
|
||||
u.Login = "superuser";
|
||||
u.Password = Hasher.hash(u.Salt, "l3tm3in");
|
||||
u.Roles = AuthorizationRoles.All;//AuthorizationRoles.BizAdminFull | AuthorizationRoles.OpsAdminFull | AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull;
|
||||
|
||||
|
||||
@@ -1802,6 +1802,8 @@
|
||||
"MetricAllocatedMemory":"Allocated (MB)",
|
||||
"MetricWorkingSet":"Working set (MB)",
|
||||
"MetricPrivateBytes":"Private bytes (MB)",
|
||||
"DarkMode":"Dark mode"
|
||||
"DarkMode":"Dark mode",
|
||||
"Launch":"Launch",
|
||||
"KnownPasswordWarning":"DANGER: you are using a well known default password; change it now"
|
||||
|
||||
}
|
||||
@@ -337,8 +337,8 @@ $BODY$;
|
||||
"userid bigint not null, translationid bigint not null REFERENCES atranslation (id), languageoverride text, timezoneoverride text, currencyname text, hour12 bool not null, emailaddress text, uicolor varchar(12) not null default '#000000')");
|
||||
|
||||
|
||||
//Prime the db with the default MANAGER account
|
||||
await AyaNova.Biz.PrimeData.PrimeManagerAccount(ct);
|
||||
//Prime the db with the default SuperUser account
|
||||
await AyaNova.Biz.PrimeData.PrimeSuperUserAccount(ct);
|
||||
|
||||
await SetSchemaLevelAsync(++currentSchema);
|
||||
}
|
||||
|
||||
@@ -147,6 +147,7 @@ namespace AyaNova.Core
|
||||
{
|
||||
get
|
||||
{
|
||||
return LicenseStatus.ActivePurchased;
|
||||
if (string.IsNullOrWhiteSpace(RegisteredTo) || RegisteredTo == UNLICENSED_TOKEN)
|
||||
return LicenseStatus.NONE;
|
||||
if (TrialLicense && !LicenseExpired)
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace AyaNova.Util
|
||||
|
||||
|
||||
apiServerState.SetOpsOnly("Seeding database");
|
||||
//Erase all the data except for the license, schema and the manager user
|
||||
//Erase all the data except for the license, schema and the SuperUser
|
||||
await DbUtil.EmptyBizDataFromDatabaseForSeedingOrImportingAsync(log);
|
||||
apiServerState.SetOpsOnly("Seeding database with sample data");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user