Überarbeitung der UserManager-Konfiguration und -Abhängigkeiten

Unnötige Paketverweise wurden aus dem API-Projekt entfernt, einschließlich Entity Framework Core und System.DirectoryServices. Ersetzte `AddDbContext` durch `AddUserManager` in `Program.cs`, um die UserManager-Dienstkonfiguration zu rationalisieren. Die Datei `Extensions.cs` wurde aktualisiert, um die Überladung der Verbindungszeichenfolge für `AddUserManager` zu entfernen, und `DependencyInjection.cs` wurde geändert, um die Einrichtung der UserManager-Infrastruktur zu vereinfachen.
This commit is contained in:
Developer 02
2025-04-16 12:50:36 +02:00
parent 8d0beab709
commit 6cd72fe755
5 changed files with 2 additions and 32 deletions

View File

@@ -73,7 +73,7 @@ try {
// Once the app is built, the password will be decrypted with Encryptor. lazy loading also acts as a call back method.
Lazy<string>? cnn_str = null;
builder.Services.AddDbContext<UserManagerDbContext>(options => options.UseSqlServer(cnn_str!.Value).EnableSensitiveDataLogging());
builder.Services.AddUserManager(options => options.UseSqlServer(cnn_str!.Value).EnableSensitiveDataLogging());
var allowedOrigins = builder.Configuration.GetSection("AllowedOrigins").Get<string[]>() ?? throw new InvalidOperationException("In appsettings there is no allowed origin.");
@@ -88,10 +88,7 @@ try {
.AllowCredentials();
});
});
//builder.Services.AddAutoMapper(typeof(DirectoryMappingProfile).Assembly);
builder.Services.AddUserManager<UserManagerDbContext>();
builder.ConfigureBySection<DirectorySearchOptions>();
builder.Services.AddDirectorySearchService(config.GetSection("DirectorySearchOptions"));
builder.Services.AddJWTService<UserReadDto>(user => new SecurityTokenDescriptor()