Browse Source

Update EfCoreOpenIddictAuthorizationRepository.cs

pull/15473/head
maliming 4 years ago
parent
commit
ca45244349
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 11
      modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Authorizations/EfCoreOpenIddictAuthorizationRepository.cs

11
modules/openiddict/src/Volo.Abp.OpenIddict.EntityFrameworkCore/Volo/Abp/OpenIddict/Authorizations/EfCoreOpenIddictAuthorizationRepository.cs

@ -82,13 +82,20 @@ public class EfCoreOpenIddictAuthorizationRepository : EfCoreRepository<IOpenIdd
public virtual async Task PruneAsync(DateTime date, CancellationToken cancellationToken = default)
{
await (from authorization in (await GetQueryableAsync())
var authorizations = await (from authorization in (await GetQueryableAsync())
join token in (await GetDbContextAsync()).Set<OpenIddictToken>()
on authorization.Id equals token.AuthorizationId into authorizationTokens
from authorizationToken in authorizationTokens.DefaultIfEmpty()
where authorization.CreationDate < date
where authorization.Status != OpenIddictConstants.Statuses.Valid ||
(authorization.Type == OpenIddictConstants.AuthorizationTypes.AdHoc && authorizationToken == null)
select authorization).ExecuteDeleteAsync(cancellationToken);
select authorization.Id).ToListAsync(cancellationToken);
await (from token in (await GetDbContextAsync()).Set<OpenIddictToken>()
where token.AuthorizationId != null && authorizations.Contains(token.AuthorizationId.Value)
select token)
.ExecuteDeleteAsync(GetCancellationToken(cancellationToken));
await (await GetDbSetAsync()).Where(x => authorizations.Contains(x.Id)).ExecuteDeleteAsync(cancellationToken);
}
}

Loading…
Cancel
Save