Browse Source
Merge pull request #25897 from abpframework/maliming/fix-identity-session-cleanup
Fall back to `SignedIn` when `LastAccessed` is null in inactive session cleanup
pull/25908/head
Engincan VESKE
5 days ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
12 additions and
8 deletions
-
modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentitySessionRepository.cs
-
modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentitySessionRepository.cs
|
|
|
@ -14,10 +14,12 @@ namespace Volo.Abp.Identity.EntityFrameworkCore; |
|
|
|
|
|
|
|
public class EfCoreIdentitySessionRepository : EfCoreRepository<IIdentityDbContext, IdentitySession, Guid>, IIdentitySessionRepository |
|
|
|
{ |
|
|
|
public EfCoreIdentitySessionRepository(IDbContextProvider<IIdentityDbContext> dbContextProvider) |
|
|
|
protected IClock Clock { get; } |
|
|
|
|
|
|
|
public EfCoreIdentitySessionRepository(IDbContextProvider<IIdentityDbContext> dbContextProvider, IClock clock) |
|
|
|
: base(dbContextProvider) |
|
|
|
{ |
|
|
|
|
|
|
|
Clock = clock; |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task<IdentitySession> FindAsync(string sessionId, CancellationToken cancellationToken = default) |
|
|
|
@ -89,7 +91,7 @@ public class EfCoreIdentitySessionRepository : EfCoreRepository<IIdentityDbConte |
|
|
|
|
|
|
|
public virtual async Task DeleteAllAsync(TimeSpan inactiveTimeSpan, CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
var now = LazyServiceProvider.LazyGetRequiredService<IClock>().Now; |
|
|
|
await DeleteDirectAsync(x => x.LastAccessed == null || x.LastAccessed < now.Subtract(inactiveTimeSpan), cancellationToken: cancellationToken); |
|
|
|
var inactiveTime = Clock.Now.Subtract(inactiveTimeSpan); |
|
|
|
await DeleteDirectAsync(x => (x.LastAccessed ?? x.SignedIn) < inactiveTime, cancellationToken: cancellationToken); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -15,10 +15,12 @@ namespace Volo.Abp.Identity.MongoDB; |
|
|
|
|
|
|
|
public class MongoIdentitySessionRepository : MongoDbRepository<IAbpIdentityMongoDbContext, IdentitySession, Guid>, IIdentitySessionRepository |
|
|
|
{ |
|
|
|
public MongoIdentitySessionRepository(IMongoDbContextProvider<IAbpIdentityMongoDbContext> dbContextProvider) |
|
|
|
protected IClock Clock { get; } |
|
|
|
|
|
|
|
public MongoIdentitySessionRepository(IMongoDbContextProvider<IAbpIdentityMongoDbContext> dbContextProvider, IClock clock) |
|
|
|
: base(dbContextProvider) |
|
|
|
{ |
|
|
|
|
|
|
|
Clock = clock; |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task<IdentitySession> FindAsync(string sessionId, CancellationToken cancellationToken = default) |
|
|
|
@ -93,7 +95,7 @@ public class MongoIdentitySessionRepository : MongoDbRepository<IAbpIdentityMong |
|
|
|
|
|
|
|
public virtual async Task DeleteAllAsync(TimeSpan inactiveTimeSpan, CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
var now = LazyServiceProvider.LazyGetRequiredService<IClock>().Now; |
|
|
|
await DeleteDirectAsync(x => x.LastAccessed == null || x.LastAccessed < now.Subtract(inactiveTimeSpan), cancellationToken: cancellationToken); |
|
|
|
var inactiveTime = Clock.Now.Subtract(inactiveTimeSpan); |
|
|
|
await DeleteDirectAsync(x => (x.LastAccessed ?? x.SignedIn) < inactiveTime, cancellationToken: cancellationToken); |
|
|
|
} |
|
|
|
} |
|
|
|
|