From 78eb588712c71e0fac81b6b7dcb7d5068abfaf2b Mon Sep 17 00:00:00 2001 From: maliming Date: Tue, 13 Jun 2023 19:33:40 +0800 Subject: [PATCH 1/3] 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) From f4d38b9acded6c341f2c1910411c1fe645388fbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 13 Jun 2023 18:30:09 +0300 Subject: [PATCH 2/3] Resolve #16809: Documentation should not encourage IQueryable usage in AppServices --- docs/en/Repositories.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/en/Repositories.md b/docs/en/Repositories.md index 23ed2371dd..fb6fd6eac6 100644 --- a/docs/en/Repositories.md +++ b/docs/en/Repositories.md @@ -140,9 +140,9 @@ public async Task> GetListAsync(string filter) Any standard LINQ method can be used over the `IQueryable` returned from the repository. -> This sample uses `ToList()` method, but it is **strongly suggested to use the asynchronous methods** to perform database queries, like `ToListAsync()` for this example. -> -> See the **IQueryable & Async Operations** section to learn how you can do it. +> This sample uses `ToList()` method, but it is **strongly suggested to use the asynchronous methods** to perform database queries, like `ToListAsync()` for this example. See the **`IQueryable` & Async Operations** section to learn how you can do it. + +> **Exposing `IQueryable` to outside of a repository** class may leak your data access logic to the application layer. If you want to strictly follow the **layered architecture** principles, you can consider to implement a **custom repository** class and wrap your data access logic inside your repository class. You can see [EF Core](Entity-Framework-Core.md) or [MongoDb](MongoDB.md) document to learn how to create custom repository classes for your application. ### Bulk Operations From 3634e4c7fdf3d9609852994a8c601c5d7b1c4059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 13 Jun 2023 18:33:34 +0300 Subject: [PATCH 3/3] Update Repositories.md --- docs/en/Repositories.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/Repositories.md b/docs/en/Repositories.md index fb6fd6eac6..61383898e6 100644 --- a/docs/en/Repositories.md +++ b/docs/en/Repositories.md @@ -142,7 +142,7 @@ Any standard LINQ method can be used over the `IQueryable` returned from the rep > This sample uses `ToList()` method, but it is **strongly suggested to use the asynchronous methods** to perform database queries, like `ToListAsync()` for this example. See the **`IQueryable` & Async Operations** section to learn how you can do it. -> **Exposing `IQueryable` to outside of a repository** class may leak your data access logic to the application layer. If you want to strictly follow the **layered architecture** principles, you can consider to implement a **custom repository** class and wrap your data access logic inside your repository class. You can see [EF Core](Entity-Framework-Core.md) or [MongoDb](MongoDB.md) document to learn how to create custom repository classes for your application. +> **Exposing `IQueryable` to outside of a repository** class may leak your data access logic to the application layer. If you want to strictly follow the **layered architecture** principles, you can consider to implement a custom repository class and wrap your data access logic inside your repository class. You can see the ***Custom Repositories*** section to learn how to create custom repository classes for your application. ### Bulk Operations