Browse Source

Update OpenIddictAuthorizationManager.FindAsync() to return an array of authorizations instead of a single element

pull/503/head
Kévin Chalet 9 years ago
parent
commit
5ce37e4ad2
  1. 7
      src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs
  2. 7
      src/OpenIddict.Core/Stores/IOpenIddictAuthorizationStore.cs
  3. 9
      src/OpenIddict.Core/Stores/OpenIddictAuthorizationStore.cs
  4. 9
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictAuthorizationStore.cs

7
src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs

@ -173,16 +173,17 @@ namespace OpenIddict.Core
} }
/// <summary> /// <summary>
/// Retrieves an authorization using its associated subject/client. /// Retrieves the authorizations corresponding to the specified
/// subject and associated with the application identifier.
/// </summary> /// </summary>
/// <param name="subject">The subject associated with the authorization.</param> /// <param name="subject">The subject associated with the authorization.</param>
/// <param name="client">The client associated with the authorization.</param> /// <param name="client">The client associated with the authorization.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation, /// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the authorization corresponding to the subject/client. /// whose result returns the authorizations corresponding to the subject/client.
/// </returns> /// </returns>
public virtual Task<TAuthorization> FindAsync([NotNull] string subject, [NotNull] string client, CancellationToken cancellationToken) public virtual Task<ImmutableArray<TAuthorization>> FindAsync([NotNull] string subject, [NotNull] string client, CancellationToken cancellationToken)
{ {
if (string.IsNullOrEmpty(subject)) if (string.IsNullOrEmpty(subject))
{ {

7
src/OpenIddict.Core/Stores/IOpenIddictAuthorizationStore.cs

@ -72,16 +72,17 @@ namespace OpenIddict.Core
Task DeleteAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); Task DeleteAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves an authorization using its associated subject/client. /// Retrieves the authorizations corresponding to the specified
/// subject and associated with the application identifier.
/// </summary> /// </summary>
/// <param name="subject">The subject associated with the authorization.</param> /// <param name="subject">The subject associated with the authorization.</param>
/// <param name="client">The client associated with the authorization.</param> /// <param name="client">The client associated with the authorization.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation, /// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the authorization corresponding to the subject/client. /// whose result returns the authorizations corresponding to the subject/client.
/// </returns> /// </returns>
Task<TAuthorization> FindAsync([NotNull] string subject, [NotNull] string client, CancellationToken cancellationToken); Task<ImmutableArray<TAuthorization>> FindAsync([NotNull] string subject, [NotNull] string client, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves an authorization using its unique identifier. /// Retrieves an authorization using its unique identifier.

9
src/OpenIddict.Core/Stores/OpenIddictAuthorizationStore.cs

@ -85,16 +85,17 @@ namespace OpenIddict.Core
public abstract Task DeleteAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); public abstract Task DeleteAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves an authorization using its associated subject/client. /// Retrieves the authorizations corresponding to the specified
/// subject and associated with the application identifier.
/// </summary> /// </summary>
/// <param name="subject">The subject associated with the authorization.</param> /// <param name="subject">The subject associated with the authorization.</param>
/// <param name="client">The client associated with the authorization.</param> /// <param name="client">The client associated with the authorization.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation, /// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the authorization corresponding to the subject/client. /// whose result returns the authorizations corresponding to the subject/client.
/// </returns> /// </returns>
public virtual Task<TAuthorization> FindAsync([NotNull] string subject, [NotNull] string client, CancellationToken cancellationToken) public virtual Task<ImmutableArray<TAuthorization>> FindAsync([NotNull] string subject, [NotNull] string client, CancellationToken cancellationToken)
{ {
if (string.IsNullOrEmpty(subject)) if (string.IsNullOrEmpty(subject))
{ {
@ -117,7 +118,7 @@ namespace OpenIddict.Core
select authorization; select authorization;
} }
return GetAsync(Query, cancellationToken); return ListAsync(Query, cancellationToken);
} }
/// <summary> /// <summary>

9
src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictAuthorizationStore.cs

@ -188,16 +188,17 @@ namespace OpenIddict.EntityFrameworkCore
} }
/// <summary> /// <summary>
/// Retrieves an authorization using its associated subject/client. /// Retrieves the authorizations corresponding to the specified
/// subject and associated with the application identifier.
/// </summary> /// </summary>
/// <param name="subject">The subject associated with the authorization.</param> /// <param name="subject">The subject associated with the authorization.</param>
/// <param name="client">The client associated with the authorization.</param> /// <param name="client">The client associated with the authorization.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns> /// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation, /// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the authorization corresponding to the subject/client. /// whose result returns the authorizations corresponding to the subject/client.
/// </returns> /// </returns>
public override Task<TAuthorization> FindAsync([NotNull] string subject, [NotNull] string client, CancellationToken cancellationToken) public override async Task<ImmutableArray<TAuthorization>> FindAsync([NotNull] string subject, [NotNull] string client, CancellationToken cancellationToken)
{ {
if (string.IsNullOrEmpty(subject)) if (string.IsNullOrEmpty(subject))
{ {
@ -225,7 +226,7 @@ namespace OpenIddict.EntityFrameworkCore
select authorization; select authorization;
} }
return Query(Authorizations, Applications).SingleOrDefaultAsync(cancellationToken); return ImmutableArray.Create(await Query(Authorizations, Applications).ToArrayAsync(cancellationToken));
} }
/// <summary> /// <summary>

Loading…
Cancel
Save