Browse Source

ClientRepository

pull/558/head
Yunus Emre Kalkan 8 years ago
parent
commit
a16c109992
  1. 10
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/Client.cs
  2. 20
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/Clients/ClientRepository.cs

10
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();
}
}
}

20
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<Client> UpdateAsync(Client entity, bool autoSave = false, CancellationToken cancellationToken = default)
{
var secrets = DbContext.Set<ClientSecret>().Where(s => s.ClientId == entity.Id);
foreach (var secret in secrets)
{
DbContext.Set<ClientSecret>().Remove(secret);
}
var claims = DbContext.Set<ClientClaim>().Where(s => s.ClientId == entity.Id);
foreach (var claim in claims)
{
DbContext.Set<ClientClaim>().Remove(claim);
}
return await base.UpdateAsync(entity, autoSave, cancellationToken);
}
public override IQueryable<Client> WithDetails()
{
return GetQueryable().IncludeDetails();

Loading…
Cancel
Save