From 78eb588712c71e0fac81b6b7dcb7d5068abfaf2b Mon Sep 17 00:00:00 2001 From: maliming Date: Tue, 13 Jun 2023 19:33:40 +0800 Subject: [PATCH] Incorrect filtering for Booleans has been fixed in the IdentityUserRepository. Resolve #16818 https://github.com/abpframework/abp/pull/15687 --- .../EntityFrameworkCore/EfCoreIdentityUserRepository.cs | 8 ++++---- .../Abp/Identity/MongoDB/MongoIdentityUserRepository.cs | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs b/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs index 60abbb3054..2dc1963505 100644 --- a/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs +++ b/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs @@ -252,10 +252,10 @@ public class EfCoreIdentityUserRepository : EfCoreRepository x.Email == emailAddress) .WhereIf(!string.IsNullOrWhiteSpace(name), x => x.Name == name) .WhereIf(!string.IsNullOrWhiteSpace(surname), x => x.Surname == surname) - .WhereIf(isLockedOut.HasValue, x => x.LockoutEnabled && x.LockoutEnd.Value.CompareTo(DateTime.UtcNow) > 0) - .WhereIf(notActive.HasValue, x => !x.IsActive) - .WhereIf(emailConfirmed.HasValue, x => x.EmailConfirmed) - .WhereIf(isExternal.HasValue, x => x.IsExternal) + .WhereIf(isLockedOut.HasValue, x => (x.LockoutEnabled && x.LockoutEnd.HasValue && x.LockoutEnd.Value.CompareTo(DateTime.UtcNow) > 0) == isLockedOut.Value) + .WhereIf(notActive.HasValue, x => x.IsActive == !notActive.Value) + .WhereIf(emailConfirmed.HasValue, x => x.EmailConfirmed == emailConfirmed.Value) + .WhereIf(isExternal.HasValue, x => x.IsExternal == isExternal.Value) .WhereIf(maxCreationTime != null, p => p.CreationTime <= maxCreationTime) .WhereIf(minCreationTime != null, p => p.CreationTime >= minCreationTime) .WhereIf(maxModifitionTime != null, p => p.LastModificationTime <= maxModifitionTime) diff --git a/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserRepository.cs b/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserRepository.cs index ae805d9a03..552e22afbe 100644 --- a/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserRepository.cs +++ b/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserRepository.cs @@ -257,10 +257,11 @@ public class MongoIdentityUserRepository : MongoDbRepository>(!string.IsNullOrWhiteSpace(emailAddress), x => x.Email == emailAddress) .WhereIf>(!string.IsNullOrWhiteSpace(name), x => x.Name == name) .WhereIf>(!string.IsNullOrWhiteSpace(surname), x => x.Surname == surname) - .WhereIf>(isLockedOut.HasValue, x => x.LockoutEnabled && x.LockoutEnd > DateTimeOffset.UtcNow) - .WhereIf>(notActive.HasValue, x => !x.IsActive) - .WhereIf>(emailConfirmed.HasValue, x => x.EmailConfirmed) - .WhereIf>(isExternal.HasValue, x => x.IsExternal) + .WhereIf>(isLockedOut.HasValue && isLockedOut.Value, x => x.LockoutEnabled && x.LockoutEnd != null && x.LockoutEnd > DateTimeOffset.UtcNow) + .WhereIf>(isLockedOut.HasValue && !isLockedOut.Value, x => !(x.LockoutEnabled && x.LockoutEnd != null && x.LockoutEnd > DateTimeOffset.UtcNow)) + .WhereIf>(notActive.HasValue, x => x.IsActive == !notActive.Value) + .WhereIf>(emailConfirmed.HasValue, x => x.EmailConfirmed == emailConfirmed.Value) + .WhereIf>(isExternal.HasValue, x => x.IsExternal == isExternal.Value) .WhereIf>(maxCreationTime != null, p => p.CreationTime <= maxCreationTime) .WhereIf>(minCreationTime != null, p => p.CreationTime >= minCreationTime) .WhereIf>(maxModifitionTime != null, p => p.LastModificationTime <= maxModifitionTime)