|
|
|
@ -263,6 +263,44 @@ namespace OpenIddict.Core |
|
|
|
/// </returns>
|
|
|
|
public abstract Task<ImmutableArray<TResult>> ListAsync<TResult>([NotNull] Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Lists the ad-hoc authorizations that are marked as invalid or have no
|
|
|
|
/// valid token attached and that can be safely removed from the database.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="count">The number of results to return.</param>
|
|
|
|
/// <param name="offset">The number of results to skip.</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 all the elements returned when executing the specified query.
|
|
|
|
/// </returns>
|
|
|
|
public virtual Task<ImmutableArray<TAuthorization>> ListInvalidAsync([CanBeNull] int? count, [CanBeNull] int? offset, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
IQueryable<TAuthorization> Query(IQueryable<TAuthorization> authorizations) |
|
|
|
{ |
|
|
|
var query = (from authorization in authorizations |
|
|
|
where authorization.Status != OpenIddictConstants.Statuses.Valid || |
|
|
|
(authorization.Type == OpenIddictConstants.AuthorizationTypes.AdHoc && |
|
|
|
!authorization.Tokens.Any(token => token.Status == OpenIddictConstants.Statuses.Valid)) |
|
|
|
orderby authorization.Id |
|
|
|
select authorization).AsQueryable(); |
|
|
|
|
|
|
|
if (offset.HasValue) |
|
|
|
{ |
|
|
|
query = query.Skip(offset.Value); |
|
|
|
} |
|
|
|
|
|
|
|
if (count.HasValue) |
|
|
|
{ |
|
|
|
query = query.Take(count.Value); |
|
|
|
} |
|
|
|
|
|
|
|
return query; |
|
|
|
} |
|
|
|
|
|
|
|
return ListAsync(Query, cancellationToken); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Sets the status associated with an authorization.
|
|
|
|
/// </summary>
|
|
|
|
|