diff --git a/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpIdentityAspNetCoreModule.cs b/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpIdentityAspNetCoreModule.cs index 974f81a201..9b38e2e25a 100644 --- a/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpIdentityAspNetCoreModule.cs +++ b/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpIdentityAspNetCoreModule.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Modularity; +using static Volo.Abp.Identity.AspNetCore.AbpSecurityStampValidatorCallback; namespace Volo.Abp.Identity.AspNetCore; @@ -41,4 +42,12 @@ public class AbpIdentityAspNetCoreModule : AbpModule .AddIdentityCookies(); } } + + public override void PostConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.UpdatePrincipal(); + }); + } } diff --git a/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/SecurityStampValidatorOptionsExtensions.cs b/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/SecurityStampValidatorOptionsExtensions.cs new file mode 100644 index 0000000000..4d1a26b03c --- /dev/null +++ b/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/SecurityStampValidatorOptionsExtensions.cs @@ -0,0 +1,18 @@ +using Microsoft.AspNetCore.Identity; +using static Volo.Abp.Identity.AspNetCore.AbpSecurityStampValidatorCallback; + +namespace Volo.Abp.Identity.AspNetCore; + +public static class SecurityStampValidatorOptionsExtensions +{ + public static SecurityStampValidatorOptions UpdatePrincipal(this SecurityStampValidatorOptions options) + { + var previousOnRefreshingPrincipal = options.OnRefreshingPrincipal; + options.OnRefreshingPrincipal = async context => + { + await SecurityStampValidatorCallback.UpdatePrincipal(context); + await previousOnRefreshingPrincipal?.Invoke(context); + }; + return options; + } +}