From 4b4bbfd3757f4a56223e8ad3bdfc4d9d12a87a5b Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 20 Mar 2024 15:19:11 +0800 Subject: [PATCH] Clear dynamic claims cache when calling `UpdateUserAsync` method. --- .../Volo/Abp/Identity/IdentityUserManager.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs index a8e6a08ead..4ca6d9fab3 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Numerics; using System.Threading; using System.Threading.Tasks; using JetBrains.Annotations; @@ -13,7 +12,6 @@ using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Services; using Volo.Abp.EventBus.Distributed; -using Volo.Abp.EventBus.Local; using Volo.Abp.Identity.Settings; using Volo.Abp.Security.Claims; using Volo.Abp.Settings; @@ -97,6 +95,18 @@ public class IdentityUserManager : UserManager, IDomainService return await base.DeleteAsync(user); } + protected async override Task UpdateUserAsync(IdentityUser user) + { + var result = await base.UpdateUserAsync(user); + + if (result.Succeeded) + { + await DynamicClaimCache.RemoveAsync(AbpDynamicClaimCacheItem.CalculateCacheKey(user.Id, user.TenantId), token: CancellationToken); + } + + return result; + } + public virtual async Task GetByIdAsync(Guid id) { var user = await Store.FindByIdAsync(id.ToString(), CancellationToken);