From a5054d96a9266c7d28ad1591007b51c1e54137eb Mon Sep 17 00:00:00 2001 From: malik masis Date: Thu, 4 Aug 2022 11:30:10 +0300 Subject: [PATCH 1/2] Removed dependency of DateTimeOffset --- .../EntityFrameworkCore/EfCoreIdentityUserRepository.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 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 9a989a1ad6..0b8efc4af5 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 @@ -161,7 +161,7 @@ public class EfCoreIdentityUserRepository : EfCoreRepository x.UserName == userName) .WhereIf(!string.IsNullOrWhiteSpace(phoneNumber), x => x.PhoneNumber == phoneNumber) .WhereIf(!string.IsNullOrWhiteSpace(emailAddress), x => x.Email == emailAddress) - .WhereIf(isLockedOut == true, x => x.LockoutEnabled && x.LockoutEnd > DateTimeOffset.UtcNow) + .WhereIf(isLockedOut == true, x => x.LockoutEnabled && x.LockoutEnd.Value.CompareTo(DateTime.UtcNow) > 0) .WhereIf(notActive == true, x => !x.IsActive) .OrderBy(sorting.IsNullOrWhiteSpace() ? nameof(IdentityUser.UserName) : sorting) .PageBy(skipCount, maxResultCount) @@ -225,7 +225,7 @@ public class EfCoreIdentityUserRepository : EfCoreRepository x.UserName == userName) .WhereIf(!string.IsNullOrWhiteSpace(phoneNumber), x => x.PhoneNumber == phoneNumber) .WhereIf(!string.IsNullOrWhiteSpace(emailAddress), x => x.Email == emailAddress) - .WhereIf(isLockedOut == true, x => x.LockoutEnabled && x.LockoutEnd > DateTimeOffset.UtcNow) + .WhereIf(isLockedOut == true, x => x.LockoutEnabled && x.LockoutEnd.Value.CompareTo(DateTime.UtcNow) > 0) .WhereIf(notActive == true, x => !x.IsActive) .LongCountAsync(GetCancellationToken(cancellationToken)); } From 60dc56a05af6cbfde853828748d1e84b660d8ad8 Mon Sep 17 00:00:00 2001 From: malik masis Date: Thu, 4 Aug 2022 11:30:32 +0300 Subject: [PATCH 2/2] Fixed unit tests --- .../Volo/Abp/Identity/AbpIdentityTestDataBuilder.cs | 4 ++++ .../Volo/Abp/Identity/IdentityUserRepository_Tests.cs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/AbpIdentityTestDataBuilder.cs b/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/AbpIdentityTestDataBuilder.cs index 2381748d68..788f974b5e 100644 --- a/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/AbpIdentityTestDataBuilder.cs +++ b/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/AbpIdentityTestDataBuilder.cs @@ -117,6 +117,8 @@ public class AbpIdentityTestDataBuilder : ITransientDependency await _userRepository.InsertAsync(adminUser); var john = new IdentityUser(_testData.UserJohnId, "john.nash", "john.nash@abp.io"); + john.LockoutEnabled = true; + john.LockoutEnd = DateTime.UtcNow.AddDays(1); john.AddRole(_moderatorRole.Id); john.AddRole(_supporterRole.Id); john.AddOrganizationUnit(_ou111.Id); @@ -132,6 +134,8 @@ public class AbpIdentityTestDataBuilder : ITransientDependency await _userRepository.InsertAsync(david); var neo = new IdentityUser(_testData.UserNeoId, "neo", "neo@abp.io"); + neo.LockoutEnabled = true; + neo.LockoutEnd = DateTime.UtcNow.AddDays(1); neo.AddRole(_supporterRole.Id); neo.AddClaim(_guidGenerator, new Claim("TestClaimType", "43")); neo.AddOrganizationUnit(_ou111.Id); diff --git a/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityUserRepository_Tests.cs b/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityUserRepository_Tests.cs index de7f23cb4b..3931ecbafe 100644 --- a/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityUserRepository_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.TestBase/Volo/Abp/Identity/IdentityUserRepository_Tests.cs @@ -92,7 +92,7 @@ public abstract class IdentityUserRepository_Tests : AbpIdentity [Fact] public async Task GetListAsync() { - var users = await UserRepository.GetListAsync("UserName DESC", 5, 0, "n"); + var users = await UserRepository.GetListAsync("UserName DESC", 5, 0, "n", isLockedOut: true); users.Count.ShouldBeGreaterThan(1); users.Count.ShouldBeLessThanOrEqualTo(5);