|
|
|
@ -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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|