Skip to content

Commit

Permalink
Change current tenant in AbpSecurityStampValidator.
Browse files Browse the repository at this point in the history
  • Loading branch information
maliming committed Feb 23, 2021
1 parent a031a3d commit caf927c
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,41 @@
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);
}
}
}
}

0 comments on commit caf927c

Please sign in to comment.