Browse Source

Keep the claims when refreshing principal

pull/18367/head
liangshiwei 2 years ago
parent
commit
07ab777814
  1. 9
      modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpIdentityAspNetCoreModule.cs
  2. 18
      modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/SecurityStampValidatorOptionsExtensions.cs

9
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<SecurityStampValidatorOptions>(options =>
{
options.UpdatePrincipal();
});
}
}

18
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;
}
}
Loading…
Cancel
Save