0
aZee created
- ABP Framework version: v8.2.3
Hello, can I replace IdentitySessionDynamicClaimsPrincipalContributor with my own implementation? If so, how can I do it?
2 Answer(s)
-
0
Hi,
Of course, you can replace it.
for example:
[Dependency(ReplaceServices = true)] [ExposeServices(typeof(IdentitySessionDynamicClaimsPrincipalContributor))] public class MyIdentitySessionDynamicClaimsPrincipalContributor : IdentitySessionDynamicClaimsPrincipalContributor { public override Task ContributeAsync(AbpClaimsPrincipalContributorContext context) { .... return base.ContributeAsync(context); } } -
0
Hello, thank you for your reply. However, I had to use the
IServiceCollection.Replacemethod instead ofDependencyattribute. Here's my working code :MyIdentitySessionDynamicClaimsPrincipalContributor.cspublic class MyIdentitySessionDynamicClaimsPrincipalContributor : IdentitySessionDynamicClaimsPrincipalContributor { public override Task ContributeAsync(AbpClaimsPrincipalContributorContext context) { ... } }MyModule.cspublic class MyModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { ... context.Services.Replace( ServiceDescriptor.Transient< IdentitySessionDynamicClaimsPrincipalContributor, MyIdentitySessionDynamicClaimsPrincipalContributor >()); } }