mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Added LDAP migrations, made CreateObject async, moved LdapOptions to Models, fixed user password not hashed on user creation
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user