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>
/// Retrieves an authorization using its associated subject/client.
/// Retrieves the authorizations corresponding to the specified
/// subject and associated with the application identifier.
/// </summary>
/// <param name="subject">The subject 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>
/// <returns>
/// 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>
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))
{

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

@ -72,16 +72,17 @@ namespace OpenIddict.Core
Task DeleteAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken);
/// <summary>
/// Retrieves an authorization using its associated subject/client.
/// Retrieves the authorizations corresponding to the specified
/// subject and associated with the application identifier.
/// </summary>
/// <param name="subject">The subject 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>
/// <returns>
/// 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>
Task<TAuthorization> FindAsync([NotNull] string subject, [NotNull] string client, CancellationToken cancellationToken);
Task<ImmutableArray<TAuthorization>> FindAsync([NotNull] string subject, [NotNull] string client, CancellationToken cancellationToken);
/// <summary>
/// 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);
/// <summary>
/// Retrieves an authorization using its associated subject/client.
/// Retrieves the authorizations corresponding to the specified
/// subject and associated with the application identifier.
/// </summary>
/// <param name="subject">The subject 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>
/// <returns>
/// 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>
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))
{
@ -117,7 +118,7 @@ namespace OpenIddict.Core
select authorization;
}
return GetAsync(Query, cancellationToken);
return ListAsync(Query, cancellationToken);
}
/// <summary>

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

@ -188,16 +188,17 @@ namespace OpenIddict.EntityFrameworkCore
}
/// <summary>
/// Retrieves an authorization using its associated subject/client.
/// Retrieves the authorizations corresponding to the specified
/// subject and associated with the application identifier.
/// </summary>
/// <param name="subject">The subject 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>
/// <returns>
/// 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>
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))
{
@ -225,7 +226,7 @@ namespace OpenIddict.EntityFrameworkCore
select authorization;
}
return Query(Authorizations, Applications).SingleOrDefaultAsync(cancellationToken);
return ImmutableArray.Create(await Query(Authorizations, Applications).ToArrayAsync(cancellationToken));
}
/// <summary>

Loading…
Cancel
Save