Rättat rätt filer för setup
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Elias Jansson
2026-01-24 15:41:22 +01:00
parent c0463a8f5b
commit 81417b2a1c

View File

@@ -15,11 +15,15 @@ namespace Aberwyn.Controllers
{ {
private readonly IWebHostEnvironment _env; private readonly IWebHostEnvironment _env;
private readonly ILogger<SetupController> _logger; private readonly ILogger<SetupController> _logger;
private readonly string _filePath;
public SetupController(IWebHostEnvironment env, ILogger<SetupController> logger) public SetupController(IWebHostEnvironment env, ILogger<SetupController> logger)
{ {
_env = env; _env = env;
_logger = logger; _logger = logger;
var dataRoot = Path.Combine(Directory.GetCurrentDirectory(), "data"); // /app/data i containern
_filePath = Path.Combine(dataRoot, "infrastructure", "setup.json");
} }
public override void OnActionExecuting(ActionExecutingContext context) public override void OnActionExecuting(ActionExecutingContext context)
@@ -35,7 +39,7 @@ namespace Aberwyn.Controllers
[HttpPost("reset")] [HttpPost("reset")]
public IActionResult Reset() public IActionResult Reset()
{ {
var path = Path.Combine(_env.ContentRootPath, "infrastructure", "setup.json"); var path = _filePath;
var resetSettings = new SetupSettings var resetSettings = new SetupSettings
{ {
@@ -124,9 +128,8 @@ namespace Aberwyn.Controllers
model.IsConfigured = true; model.IsConfigured = true;
// Spara setup.json // Spara setup.json
var filePath = Path.Combine(_env.ContentRootPath, "infrastructure", "setup.json");
var json = JsonSerializer.Serialize(model, new JsonSerializerOptions { WriteIndented = true }); var json = JsonSerializer.Serialize(model, new JsonSerializerOptions { WriteIndented = true });
System.IO.File.WriteAllText(filePath, json); System.IO.File.WriteAllText(_filePath, json);
// Roller och admin // Roller och admin
var userManager = scope.ServiceProvider.GetRequiredService<UserManager<ApplicationUser>>(); var userManager = scope.ServiceProvider.GetRequiredService<UserManager<ApplicationUser>>();