diff --git a/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpSecurityStampValidator.cs b/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpSecurityStampValidator.cs index cf6e1f8d50..1dcc624a47 100644 --- a/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpSecurityStampValidator.cs +++ b/modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpSecurityStampValidator.cs @@ -4,29 +4,41 @@ using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; +using Volo.Abp.MultiTenancy; using Volo.Abp.Uow; namespace Volo.Abp.Identity.AspNetCore { public class AbpSecurityStampValidator : SecurityStampValidator { + protected ITenantConfigurationProvider TenantConfigurationProvider { get; } + protected ICurrentTenant CurrentTenant { get; } + public AbpSecurityStampValidator( IOptions options, SignInManager signInManager, ISystemClock systemClock, - ILoggerFactory loggerFactory) + ILoggerFactory loggerFactory, + ITenantConfigurationProvider tenantConfigurationProvider, + ICurrentTenant currentTenant) : base( - options, + options, signInManager, systemClock, loggerFactory) { + TenantConfigurationProvider = tenantConfigurationProvider; + CurrentTenant = currentTenant; } [UnitOfWork] - public override Task ValidateAsync(CookieValidatePrincipalContext context) + public override async Task ValidateAsync(CookieValidatePrincipalContext context) { - return base.ValidateAsync(context); + var tenant = await TenantConfigurationProvider.GetAsync(saveResolveResult: false); + using (CurrentTenant.Change(tenant?.Id, tenant?.Name)) + { + await base.ValidateAsync(context); + } } } }