diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/Client.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/Client.cs index 13ae8d7f6c..bb0f9d3744 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/Client.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/Client.cs @@ -158,6 +158,11 @@ namespace Volo.Abp.IdentityServer.Clients ClientSecrets.Add(new ClientSecret(Id, value, expiration, type, description)); } + public virtual void RemoveAllSecrets() + { + ClientSecrets.Clear(); + } + public virtual void AddScope([NotNull] string scope) { AllowedScopes.Add(new ClientScope(Id, scope)); @@ -192,5 +197,10 @@ namespace Volo.Abp.IdentityServer.Clients { Claims.Add(new ClientClaim(guidGenerator.Create(), Id, type, value)); } + + public virtual void RemoveAllClaims() + { + Claims.Clear(); + } } } \ No newline at end of file diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/Clients/ClientRepository.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/Clients/ClientRepository.cs index 62043562e8..3b07423bc7 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/Clients/ClientRepository.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/Clients/ClientRepository.cs @@ -42,6 +42,26 @@ namespace Volo.Abp.IdentityServer.Clients return await DbSet.CountAsync(); } + public override async Task UpdateAsync(Client entity, bool autoSave = false, CancellationToken cancellationToken = default) + { + + var secrets = DbContext.Set().Where(s => s.ClientId == entity.Id); + + foreach (var secret in secrets) + { + DbContext.Set().Remove(secret); + } + + var claims = DbContext.Set().Where(s => s.ClientId == entity.Id); + + foreach (var claim in claims) + { + DbContext.Set().Remove(claim); + } + + return await base.UpdateAsync(entity, autoSave, cancellationToken); + } + public override IQueryable WithDetails() { return GetQueryable().IncludeDetails();