Browse Source

Add a new DisplayName property to OpenIddictScope/OpenIddictScopeDescriptor

pull/561/head
Kévin Chalet 8 years ago
parent
commit
595012507e
  1. 6
      src/OpenIddict.Core/Descriptors/OpenIddictScopeDescriptor.cs
  2. 21
      src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs
  3. 22
      src/OpenIddict.Core/Stores/IOpenIddictScopeStore.cs
  4. 40
      src/OpenIddict.Core/Stores/OpenIddictScopeStore.cs
  5. 6
      src/OpenIddict.Models/OpenIddictScope.cs

6
src/OpenIddict.Core/Descriptors/OpenIddictScopeDescriptor.cs

@ -14,6 +14,12 @@ namespace OpenIddict.Core
/// </summary>
public virtual string Description { get; set; }
/// <summary>
/// Gets or sets the display name
/// associated with the scope.
/// </summary>
public virtual string DisplayName { get; set; }
/// <summary>
/// Gets or sets the unique name
/// associated with the scope.

21
src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs

@ -261,6 +261,25 @@ namespace OpenIddict.Core
return Store.GetDescriptionAsync(scope, cancellationToken);
}
/// <summary>
/// Retrieves the display name associated with a scope.
/// </summary>
/// <param name="scope">The scope.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the display name associated with the scope.
/// </returns>
public virtual Task<string> GetDisplayNameAsync([NotNull] TScope scope, CancellationToken cancellationToken = default)
{
if (scope == null)
{
throw new ArgumentNullException(nameof(scope));
}
return Store.GetDisplayNameAsync(scope, cancellationToken);
}
/// <summary>
/// Retrieves the unique identifier associated with a scope.
/// </summary>
@ -452,6 +471,7 @@ namespace OpenIddict.Core
var descriptor = new OpenIddictScopeDescriptor
{
Description = await Store.GetDescriptionAsync(scope, cancellationToken),
DisplayName = await Store.GetDisplayNameAsync(scope, cancellationToken),
Name = await Store.GetNameAsync(scope, cancellationToken)
};
@ -512,6 +532,7 @@ namespace OpenIddict.Core
}
await Store.SetDescriptionAsync(scope, descriptor.Description, cancellationToken);
await Store.SetDisplayNameAsync(scope, descriptor.DisplayName, cancellationToken);
await Store.SetNameAsync(scope, descriptor.Name, cancellationToken);
await Store.SetResourcesAsync(scope, descriptor.Resources.ToImmutableArray(), cancellationToken);
}

22
src/OpenIddict.Core/Stores/IOpenIddictScopeStore.cs

@ -122,6 +122,17 @@ namespace OpenIddict.Core
/// </returns>
Task<string> GetDescriptionAsync([NotNull] TScope scope, CancellationToken cancellationToken);
/// <summary>
/// Retrieves the display name associated with a scope.
/// </summary>
/// <param name="scope">The scope.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the display name associated with the scope.
/// </returns>
Task<string> GetDisplayNameAsync([NotNull] TScope scope, CancellationToken cancellationToken);
/// <summary>
/// Retrieves the unique identifier associated with a scope.
/// </summary>
@ -215,6 +226,17 @@ namespace OpenIddict.Core
/// </returns>
Task SetDescriptionAsync([NotNull] TScope scope, [CanBeNull] string description, CancellationToken cancellationToken);
/// <summary>
/// Sets the display name associated with a scope.
/// </summary>
/// <param name="scope">The scope.</param>
/// <param name="name">The display name associated with the scope.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
Task SetDisplayNameAsync([NotNull] TScope scope, [CanBeNull] string name, CancellationToken cancellationToken);
/// <summary>
/// Sets the name associated with a scope.
/// </summary>

40
src/OpenIddict.Core/Stores/OpenIddictScopeStore.cs

@ -196,6 +196,25 @@ namespace OpenIddict.Core
return Task.FromResult(scope.Description);
}
/// <summary>
/// Retrieves the display name associated with a scope.
/// </summary>
/// <param name="scope">The scope.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the display name associated with the scope.
/// </returns>
public virtual Task<string> GetDisplayNameAsync([NotNull] TScope scope, CancellationToken cancellationToken)
{
if (scope == null)
{
throw new ArgumentNullException(nameof(scope));
}
return Task.FromResult(scope.DisplayName);
}
/// <summary>
/// Retrieves the unique identifier associated with a scope.
/// </summary>
@ -373,6 +392,27 @@ namespace OpenIddict.Core
return Task.CompletedTask;
}
/// <summary>
/// Sets the display name associated with a scope.
/// </summary>
/// <param name="scope">The scope.</param>
/// <param name="name">The display name associated with the scope.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual Task SetDisplayNameAsync([NotNull] TScope scope, [CanBeNull] string name, CancellationToken cancellationToken)
{
if (scope == null)
{
throw new ArgumentNullException(nameof(scope));
}
scope.DisplayName = name;
return Task.CompletedTask;
}
/// <summary>
/// Sets the name associated with a scope.
/// </summary>

6
src/OpenIddict.Models/OpenIddictScope.cs

@ -36,6 +36,12 @@ namespace OpenIddict.Models
/// </summary>
public virtual string Description { get; set; }
/// <summary>
/// Gets or sets the display name
/// associated with the current scope.
/// </summary>
public virtual string DisplayName { get; set; }
/// <summary>
/// Gets or sets the unique identifier
/// associated with the current scope.

Loading…
Cancel
Save