Ü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:
parent
8d0beab709
commit
6cd72fe755
@ -25,20 +25,15 @@
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.14" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.20" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.16" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.15">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.15" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="7.0.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="NLog" Version="5.3.2" />
|
||||
<PackageReference Include="NLog.Web.AspNetCore" Version="5.3.11" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||
<PackageReference Include="System.DirectoryServices" Version="7.0.1" />
|
||||
<PackageReference Include="System.DirectoryServices.AccountManagement" Version="7.0.1" />
|
||||
<PackageReference Include="System.DirectoryServices.Protocols" Version="7.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -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.");
|
||||
|
||||
@ -89,9 +89,6 @@ try {
|
||||
});
|
||||
});
|
||||
|
||||
//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()
|
||||
|
||||
@ -22,12 +22,4 @@ public static class Extensions
|
||||
services.AddUserManagerApplication();
|
||||
return services;
|
||||
}
|
||||
|
||||
public static IServiceCollection AddUserManager<TDbContext>(this IServiceCollection services, string connectionString)
|
||||
where TDbContext : DbContext, IUserManagerDbContext
|
||||
{
|
||||
services.AddUserManagerInfrastructure(connectionString);
|
||||
services.AddUserManagerApplication();
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,13 +39,4 @@ public static class DependencyInjection
|
||||
public static IServiceCollection AddUserManagerInfrastructure(this IServiceCollection services, Action<DbContextOptionsBuilder> optionsAction) => services
|
||||
.AddDbContext<UserManagerDbContext>(optionsAction)
|
||||
.AddUserManagerInfrastructure<UserManagerDbContext>();
|
||||
|
||||
/// <summary>
|
||||
/// Adds the UserManager services and repositories to the specified <see cref="IServiceCollection"/>.
|
||||
/// This method registers the necessary mappings, repositories, services and <see cref="UserManagerDbContext"/> for the UserManager.
|
||||
/// </summary>
|
||||
/// <param name="services">The IServiceCollection to which the services will be added.</param>
|
||||
/// <returns>The updated IServiceCollection.</returns>
|
||||
public static IServiceCollection AddUserManagerInfrastructure(this IServiceCollection services, string connectionString) => services
|
||||
.AddUserManagerInfrastructure(options => options.UseSqlServer(connectionString).EnableSensitiveDataLogging());
|
||||
}
|
||||
|
||||
@ -28,11 +28,6 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DigitalData.Core.Infrastructure" Version="2.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.16" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.15">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.15" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user