From 739db128cd34d5aef379669f863a6d89d95e1e97 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 12 Aug 2020 19:29:25 +0000 Subject: [PATCH] --- .../ControllerHelpers/ApiServerState.cs | 2 +- .../AyaNova/Controllers/ApiRootController.cs | 4 +-- .../Controllers/ServerStateController.cs | 33 ++++++++++++++++++- server/AyaNova/util/ServerBootConfig.cs | 4 +++ 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/server/AyaNova/ControllerHelpers/ApiServerState.cs b/server/AyaNova/ControllerHelpers/ApiServerState.cs index baf90612..f9308598 100644 --- a/server/AyaNova/ControllerHelpers/ApiServerState.cs +++ b/server/AyaNova/ControllerHelpers/ApiServerState.cs @@ -44,7 +44,7 @@ namespace AyaNova.Api.ControllerHelpers //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* SuperUser account can login to make changes"; + var msg = $"{reason}\r\nLogin as SuperUser to start evaluation / install license"; SetState(ServerState.OpsOnly, msg); SYSTEM_LOCK = true; } diff --git a/server/AyaNova/Controllers/ApiRootController.cs b/server/AyaNova/Controllers/ApiRootController.cs index b7398f92..243446a9 100644 --- a/server/AyaNova/Controllers/ApiRootController.cs +++ b/server/AyaNova/Controllers/ApiRootController.cs @@ -41,7 +41,7 @@ namespace AyaNova.Api.Controllers //https://superuser.com/questions/361297/what-colour-is-the-dark-green-on-old-fashioned-green-screen-computer-displays var errorBlock = string.Empty; if (serverState.IsSystemLocked) - errorBlock = $@"

SERVER ERROR

{serverState.Reason}

"; + errorBlock = $@"

SERVER LOCKED

{serverState.Reason}

"; var resp = $@" @@ -444,7 +444,7 @@ namespace AyaNova.Api.Controllers DBSchemaVersion = AySchema.currentSchema, ServerLocalTime = DateUtil.ServerDateTimeString(System.DateTime.UtcNow), ServerTimeZone = TimeZoneInfo.Local.Id, - ServerDbId= AyaNova.Core.License.ServerDbId, + ServerDbId = AyaNova.Core.License.ServerDbId, License = AyaNova.Core.License.LicenseInfoAsJson } }); diff --git a/server/AyaNova/Controllers/ServerStateController.cs b/server/AyaNova/Controllers/ServerStateController.cs index fe9deae1..0e873d71 100644 --- a/server/AyaNova/Controllers/ServerStateController.cs +++ b/server/AyaNova/Controllers/ServerStateController.cs @@ -9,6 +9,7 @@ using AyaNova.Biz; using AyaNova.Models; using System.ComponentModel.DataAnnotations; using Microsoft.Extensions.Hosting; +using AyaNova.Util; namespace AyaNova.Api.Controllers @@ -135,8 +136,38 @@ namespace AyaNova.Api.Controllers return Accepted(); } - //------------ + + + /// + /// Get server configuration + /// + /// Active server configuration + [HttpGet("active-configuration")] + public ActionResult GetActiveConfiguration() + { + if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.ServerState)) + return StatusCode(403, new ApiNotAuthorizedResponse()); + + + return Ok(ApiOkResponse.Response( + new + { + AYANOVA_DEFAULT_TRANSLATION = ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION, + AYANOVA_USE_URLS = ServerBootConfig.AYANOVA_USE_URLS, + AYANOVA_DB_CONNECTION = ServerBootConfig.AYANOVA_DB_CONNECTION, + AYANOVA_FOLDER_USER_FILES = ServerBootConfig.AYANOVA_FOLDER_USER_FILES, + AYANOVA_FOLDER_BACKUP_FILES = ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES, + AYANOVA_BACKUP_PG_DUMP_PATH = ServerBootConfig.AYANOVA_BACKUP_PG_DUMP_PATH, + AYANOVA_LOG_PATH = ServerBootConfig.AYANOVA_LOG_PATH, + AYANOVA_LOG_LEVEL = ServerBootConfig.AYANOVA_LOG_LEVEL, + AYANOVA_LOG_ENABLE_LOGGER_DIAGNOSTIC_LOG = ServerBootConfig.AYANOVA_LOG_ENABLE_LOGGER_DIAGNOSTIC_LOG + })); + } + + + //------------ + } } \ No newline at end of file diff --git a/server/AyaNova/util/ServerBootConfig.cs b/server/AyaNova/util/ServerBootConfig.cs index 175c8c46..a932a621 100644 --- a/server/AyaNova/util/ServerBootConfig.cs +++ b/server/AyaNova/util/ServerBootConfig.cs @@ -19,16 +19,19 @@ namespace AyaNova.Util #endif //TEST MODE - BOOT WILL ERASE DB AND GENERATE SAMPLE DATA EVERY TIME + //** Not intended for end users internal static bool AYANOVA_SERVER_TEST_MODE { get; set; } internal static decimal AYANOVA_SERVER_TEST_MODE_TZ_OFFSET { get; set; } internal static string AYANOVA_SERVER_TEST_MODE_SEEDLEVEL { get; set; } //CONTENTROOTPATH + //** Not intended for end users internal static string AYANOVA_CONTENT_ROOT_PATH { get; set; } //Note: set in startup.cs, not in program.cs as it requires startup IHostingEnvironment //LANGUAGE / Translation internal static string AYANOVA_DEFAULT_TRANSLATION { get; set; } + //** Not intended for end users internal static long AYANOVA_DEFAULT_TRANSLATION_ID { get; set; } //internal setting set at boot by TranslationBiz::ValidateTranslations //API @@ -37,6 +40,7 @@ namespace AyaNova.Util //DATABASE internal static string AYANOVA_DB_CONNECTION { get; set; } + //** Not intended for end users internal static bool AYANOVA_PERMANENTLY_ERASE_DATABASE { get; set; } //FILE FOLDERS