chore(di): register ILdapGroupRoleMappingService
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using ZB.MOM.WW.OtOpcUa.Configuration.Services;
|
||||||
|
|
||||||
namespace ZB.MOM.WW.OtOpcUa.Configuration;
|
namespace ZB.MOM.WW.OtOpcUa.Configuration;
|
||||||
|
|
||||||
@@ -22,6 +23,16 @@ public static class ServiceCollectionExtensions
|
|||||||
$"Connection string '{ConnectionStringName}' is required. Add it to appsettings.json or the OTOPCUA_CONFIG_CONNECTION env var.");
|
$"Connection string '{ConnectionStringName}' is required. Add it to appsettings.json or the OTOPCUA_CONFIG_CONNECTION env var.");
|
||||||
|
|
||||||
services.AddDbContextFactory<OtOpcUaConfigDbContext>(opt => opt.UseSqlServer(connectionString));
|
services.AddDbContextFactory<OtOpcUaConfigDbContext>(opt => opt.UseSqlServer(connectionString));
|
||||||
|
|
||||||
|
// AddDbContextFactory registers only the IDbContextFactory<> — it does NOT also register
|
||||||
|
// a scoped OtOpcUaConfigDbContext. Config services that take the context directly (e.g.
|
||||||
|
// LdapGroupRoleMappingService) need a scoped instance, so bridge one off the factory.
|
||||||
|
services.AddScoped(sp => sp.GetRequiredService<IDbContextFactory<OtOpcUaConfigDbContext>>().CreateDbContext());
|
||||||
|
|
||||||
|
// Config-DB services consumed by both the AdminUI (RoleGrants page) and the auth/login
|
||||||
|
// host (AuthEndpoints.LoginAsync). Scoped to match the request/render scope of both callers.
|
||||||
|
services.AddScoped<ILdapGroupRoleMappingService, LdapGroupRoleMappingService>();
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user