|
|
|
@ -1,3 +1,4 @@ |
|
|
|
using System; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
using Microsoft.Extensions.Logging.Abstractions; |
|
|
|
@ -8,7 +9,10 @@ using Volo.Abp.Uow; |
|
|
|
|
|
|
|
namespace Volo.Abp.Identity; |
|
|
|
|
|
|
|
public class UserEntityUpdatedEventHandler : ILocalEventHandler<EntityUpdatedEventData<IdentityUser>>, ITransientDependency |
|
|
|
public class UserEntityUpdatedEventHandler : |
|
|
|
ILocalEventHandler<EntityUpdatedEventData<IdentityUser>>, |
|
|
|
ILocalEventHandler<EntityDeletedEventData<IdentityUser>>, |
|
|
|
ITransientDependency |
|
|
|
{ |
|
|
|
public ILogger<UserEntityUpdatedEventHandler> Logger { get; set; } |
|
|
|
|
|
|
|
@ -23,8 +27,18 @@ public class UserEntityUpdatedEventHandler : ILocalEventHandler<EntityUpdatedEve |
|
|
|
[UnitOfWork] |
|
|
|
public virtual async Task HandleEventAsync(EntityUpdatedEventData<IdentityUser> eventData) |
|
|
|
{ |
|
|
|
var userId = eventData.Entity.Id; |
|
|
|
await ClearAsync(eventData.Entity.Id, eventData.Entity.TenantId); |
|
|
|
} |
|
|
|
|
|
|
|
[UnitOfWork] |
|
|
|
public virtual async Task HandleEventAsync(EntityDeletedEventData<IdentityUser> eventData) |
|
|
|
{ |
|
|
|
await ClearAsync(eventData.Entity.Id, eventData.Entity.TenantId); |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual async Task ClearAsync(Guid userId, Guid? tenantId) |
|
|
|
{ |
|
|
|
Logger.LogDebug($"Clearing dynamic claims cache for user: {userId}"); |
|
|
|
await _cache.ClearAsync(userId, eventData.Entity.TenantId); |
|
|
|
await _cache.ClearAsync(userId, tenantId); |
|
|
|
} |
|
|
|
} |
|
|
|
|