Browse Source

Change current tenant in AbpSecurityStampValidator.

Resolve #7791
pull/7814/head
maliming 6 years ago
parent
commit
caf927cbf1
  1. 20
      modules/identity/src/Volo.Abp.Identity.AspNetCore/Volo/Abp/Identity/AspNetCore/AbpSecurityStampValidator.cs

20
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<IdentityUser>
{
protected ITenantConfigurationProvider TenantConfigurationProvider { get; }
protected ICurrentTenant CurrentTenant { get; }
public AbpSecurityStampValidator(
IOptions<SecurityStampValidatorOptions> options,
SignInManager<IdentityUser> 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);
}
}
}
}

Loading…
Cancel
Save