Browse Source

Avoid adding duplicate keys to `Properties`.

pull/10154/head
maliming 4 years ago
parent
commit
19968396c5
  1. 13
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiResource.cs
  2. 10
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiScopes/ApiScope.cs
  3. 10
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/Client.cs
  4. 17
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Grants/PersistedGrant.cs
  5. 13
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityResource.cs

13
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiResources/ApiResource.cs

@ -35,7 +35,8 @@ namespace Volo.Abp.IdentityServer.ApiResources
}
public ApiResource(Guid id, [NotNull] string name, string displayName = null, string description = null) : base(id)
public ApiResource(Guid id, [NotNull] string name, string displayName = null, string description = null)
: base(id)
{
Check.NotNull(name, nameof(name));
@ -122,7 +123,15 @@ namespace Volo.Abp.IdentityServer.ApiResources
public virtual void AddProperty([NotNull] string key, string value)
{
Properties.Add(new ApiResourceProperty(Id, key, value));
var property = FindProperty(key);
if (property == null)
{
Properties.Add(new ApiResourceProperty(Id, key, value));
}
else
{
property.Value = value;
}
}
public virtual void RemoveAllProperties()

10
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/ApiScopes/ApiScope.cs

@ -79,7 +79,15 @@ namespace Volo.Abp.IdentityServer.ApiScopes
public virtual void AddProperty([NotNull] string key, string value)
{
Properties.Add(new ApiScopeProperty(Id, key, value));
var property = FindProperty(key);
if (property == null)
{
Properties.Add(new ApiScopeProperty(Id, key, value));
}
else
{
property.Value = value;
}
}
public virtual void RemoveAllProperties()

10
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Clients/Client.cs

@ -266,7 +266,15 @@ namespace Volo.Abp.IdentityServer.Clients
public virtual void AddProperty([NotNull] string key, [NotNull] string value)
{
Properties.Add(new ClientProperty(Id, key,value));
var property = FindProperty(key);
if (property == null)
{
Properties.Add(new ClientProperty(Id, key, value));
}
else
{
property.Value = value;
}
}
public virtual void RemoveAllProperties()

17
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/Grants/PersistedGrant.cs

@ -5,14 +5,6 @@ namespace Volo.Abp.IdentityServer.Grants
{
public class PersistedGrant : AggregateRoot<Guid>
{
protected PersistedGrant()
{
}
public PersistedGrant(Guid id) : base(id)
{
}
public virtual string Key { get; set; }
public virtual string Type { get; set; }
@ -32,5 +24,14 @@ namespace Volo.Abp.IdentityServer.Grants
public virtual DateTime? ConsumedTime { get; set; }
public virtual string Data { get; set; }
protected PersistedGrant()
{
}
public PersistedGrant(Guid id)
: base(id)
{
}
}
}

13
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/IdentityResources/IdentityResource.cs

@ -56,7 +56,8 @@ namespace Volo.Abp.IdentityServer.IdentityResources
Properties = new List<IdentityResourceProperty>();
}
public IdentityResource(Guid id, IdentityServer4.Models.IdentityResource resource) : base(id)
public IdentityResource(Guid id, IdentityServer4.Models.IdentityResource resource)
: base(id)
{
Name = resource.Name;
DisplayName = resource.DisplayName;
@ -91,7 +92,15 @@ namespace Volo.Abp.IdentityServer.IdentityResources
public virtual void AddProperty([NotNull] string key, string value)
{
Properties.Add(new IdentityResourceProperty(Id, key, value));
var property = FindProperty(key);
if (property == null)
{
Properties.Add(new IdentityResourceProperty(Id, key, value));
}
else
{
property.Value = value;
}
}
public virtual void RemoveAllProperties()

Loading…
Cancel
Save