From d09011d25acea1eff021e98c9af35ae273b24f78 Mon Sep 17 00:00:00 2001 From: Polianin Nikita Date: Sat, 1 Jun 2024 06:27:49 +0300 Subject: [PATCH] feat: add create admin --- .../Controllers/Configuration/SetupController.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Endpoint/Controllers/Configuration/SetupController.cs b/Endpoint/Controllers/Configuration/SetupController.cs index 7abd5ee..ac55b56 100644 --- a/Endpoint/Controllers/Configuration/SetupController.cs +++ b/Endpoint/Controllers/Configuration/SetupController.cs @@ -28,7 +28,9 @@ namespace Mirea.Api.Endpoint.Controllers.Configuration; [MaintenanceModeIgnore] public class SetupController(ISetupToken setupToken, IMaintenanceModeNotConfigureService notConfigureService, IMemoryCache cache) : BaseController { - private const string CacheGeneralKey = "config_part"; + private const string CacheGeneralKey = "config_general"; + private const string CacheAdminKey = "config_admin"; + private GeneralConfig GeneralConfig { get => cache.Get(CacheGeneralKey) ?? new GeneralConfig(); @@ -190,6 +192,16 @@ public class SetupController(ISetupToken setupToken, IMaintenanceModeNotConfigur return Ok(true); } + [HttpPost("CreateAdmin")] + [TokenAuthentication] + [BadRequestResponse] + public ActionResult CreateAdmin([FromBody] CreateUserRequest user) + { + // todo: change CreateUserRequest to Domain entity + cache.Set(CacheAdminKey, user); + return Ok(true); + } + [HttpPost("SetLogging")] [TokenAuthentication] [BadRequestResponse]