|
|
@ -22,6 +22,8 @@ public class IdentityRoleManager : RoleManager<IdentityRole>, IDomainService |
|
|
protected IStringLocalizer<IdentityResource> Localizer { get; } |
|
|
protected IStringLocalizer<IdentityResource> Localizer { get; } |
|
|
protected ICancellationTokenProvider CancellationTokenProvider { get; } |
|
|
protected ICancellationTokenProvider CancellationTokenProvider { get; } |
|
|
protected IIdentityUserRepository UserRepository { get; } |
|
|
protected IIdentityUserRepository UserRepository { get; } |
|
|
|
|
|
protected IOrganizationUnitRepository OrganizationUnitRepository { get; } |
|
|
|
|
|
protected OrganizationUnitManager OrganizationUnitManager { get; } |
|
|
protected IDistributedCache<AbpDynamicClaimCacheItem> DynamicClaimCache { get; } |
|
|
protected IDistributedCache<AbpDynamicClaimCacheItem> DynamicClaimCache { get; } |
|
|
|
|
|
|
|
|
public IdentityRoleManager( |
|
|
public IdentityRoleManager( |
|
|
@ -33,6 +35,8 @@ public class IdentityRoleManager : RoleManager<IdentityRole>, IDomainService |
|
|
IStringLocalizer<IdentityResource> localizer, |
|
|
IStringLocalizer<IdentityResource> localizer, |
|
|
ICancellationTokenProvider cancellationTokenProvider, |
|
|
ICancellationTokenProvider cancellationTokenProvider, |
|
|
IIdentityUserRepository userRepository, |
|
|
IIdentityUserRepository userRepository, |
|
|
|
|
|
IOrganizationUnitRepository organizationUnitRepository, |
|
|
|
|
|
OrganizationUnitManager organizationUnitManager, |
|
|
IDistributedCache<AbpDynamicClaimCacheItem> dynamicClaimCache) |
|
|
IDistributedCache<AbpDynamicClaimCacheItem> dynamicClaimCache) |
|
|
: base( |
|
|
: base( |
|
|
store, |
|
|
store, |
|
|
@ -44,6 +48,8 @@ public class IdentityRoleManager : RoleManager<IdentityRole>, IDomainService |
|
|
Localizer = localizer; |
|
|
Localizer = localizer; |
|
|
CancellationTokenProvider = cancellationTokenProvider; |
|
|
CancellationTokenProvider = cancellationTokenProvider; |
|
|
UserRepository = userRepository; |
|
|
UserRepository = userRepository; |
|
|
|
|
|
OrganizationUnitRepository = organizationUnitRepository; |
|
|
|
|
|
OrganizationUnitManager = organizationUnitManager; |
|
|
DynamicClaimCache = dynamicClaimCache; |
|
|
DynamicClaimCache = dynamicClaimCache; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -84,11 +90,16 @@ public class IdentityRoleManager : RoleManager<IdentityRole>, IDomainService |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var userIdList = await UserRepository.GetUserIdListByRoleIdAsync(role.Id, cancellationToken: CancellationToken); |
|
|
var userIdList = await UserRepository.GetUserIdListByRoleIdAsync(role.Id, cancellationToken: CancellationToken); |
|
|
|
|
|
var orgList = await OrganizationUnitRepository.GetListByRoleIdAsync(role.Id, includeDetails: false, cancellationToken: CancellationToken); |
|
|
var result = await base.DeleteAsync(role); |
|
|
var result = await base.DeleteAsync(role); |
|
|
if (result.Succeeded) |
|
|
if (result.Succeeded) |
|
|
{ |
|
|
{ |
|
|
Logger.LogDebug($"Remove dynamic claims cache for users of role: {role.Id}"); |
|
|
Logger.LogDebug($"Remove dynamic claims cache for users of role: {role.Id}"); |
|
|
await DynamicClaimCache.RemoveManyAsync(userIdList.Select(userId => AbpDynamicClaimCacheItem.CalculateCacheKey(userId, role.TenantId)), token: CancellationToken); |
|
|
await DynamicClaimCache.RemoveManyAsync(userIdList.Select(userId => AbpDynamicClaimCacheItem.CalculateCacheKey(userId, role.TenantId)), token: CancellationToken); |
|
|
|
|
|
foreach (var organizationUnit in orgList) |
|
|
|
|
|
{ |
|
|
|
|
|
await OrganizationUnitManager.RemoveDynamicClaimCacheAsync(organizationUnit); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return result; |
|
|
return result; |
|
|
|