Added LDAP migrations, made CreateObject async, moved LdapOptions to Models, fixed user password not hashed on user creation

This commit is contained in:
2025-10-03 16:31:08 +02:00
parent 45b1a44ebe
commit 1f356a807f
7 changed files with 220 additions and 23 deletions

View File

@@ -3,13 +3,11 @@ using ElmahCore.Mvc;
using Serilog;
using Microsoft.AspNetCore.Authentication.Cookies;
using Berufsschule_HAM.Services;
using Berufsschule_HAM.Models;
var builder = WebApplication.CreateBuilder(args);
// Bind options
builder.Services.Configure<LdapOptions>(builder.Configuration.GetSection("Ldap"));
// Register LDAP service as singleton (it manages its own connection)
builder.Services.Configure<LdapConfig>(builder.Configuration.GetSection("Ldap"));
builder.Services.AddControllersWithViews();
builder.Services.AddEndpointsApiExplorer();
@@ -26,6 +24,7 @@ builder.Services.AddElmah<XmlFileErrorLog>(Options =>
});
builder.Services.AddSingleton<LdapService>();
builder.Services.AddSingleton<MigrationService>();
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options =>
@@ -54,4 +53,8 @@ app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
// Run migrations
using var scope = app.Services.CreateScope();
var migrationService = scope.ServiceProvider.GetRequiredService<MigrationService>();
app.Run();