From 4e169cedbb89820a0d0ee1b5eda3fad965f36753 Mon Sep 17 00:00:00 2001 From: maliming Date: Tue, 2 Nov 2021 17:12:49 +0800 Subject: [PATCH 1/2] Add `isLockedOut` and `isActive` to `IIdentityUserRepository`. --- .../Abp/Identity/IIdentityUserRepository.cs | 18 +++++++++++------- .../EfCoreIdentityUserRepository.cs | 8 ++++++++ .../MongoDB/MongoIdentityUserRepository.cs | 8 ++++++++ 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentityUserRepository.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentityUserRepository.cs index d4a3f9aff3..8b871220dc 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentityUserRepository.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentityUserRepository.cs @@ -33,19 +33,19 @@ namespace Volo.Abp.Identity ); Task FindByNormalizedEmailAsync( - [NotNull] string normalizedEmail, + [NotNull] string normalizedEmail, bool includeDetails = true, CancellationToken cancellationToken = default ); Task> GetListByClaimAsync( - Claim claim, + Claim claim, bool includeDetails = false, CancellationToken cancellationToken = default ); Task> GetListByNormalizedRoleNameAsync( - string normalizedRoleName, + string normalizedRoleName, bool includeDetails = false, CancellationToken cancellationToken = default ); @@ -61,6 +61,8 @@ namespace Volo.Abp.Identity string userName = null, string phoneNumber = null, string emailAddress = null, + bool? isLockedOut = null, + bool? isActive = null, CancellationToken cancellationToken = default ); @@ -78,10 +80,10 @@ namespace Volo.Abp.Identity Task> GetUsersInOrganizationUnitAsync( Guid organizationUnitId, CancellationToken cancellationToken = default - ); - Task> GetUsersInOrganizationsListAsync( - List organizationUnitIds, - CancellationToken cancellationToken = default + ); + Task> GetUsersInOrganizationsListAsync( + List organizationUnitIds, + CancellationToken cancellationToken = default ); Task> GetUsersInOrganizationUnitWithChildrenAsync( @@ -96,6 +98,8 @@ namespace Volo.Abp.Identity string userName = null, string phoneNumber = null, string emailAddress = null, + bool? isLockedOut = null, + bool? isActive = null, CancellationToken cancellationToken = default ); } 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 bdb03591c1..77e9607cdf 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 @@ -141,6 +141,8 @@ namespace Volo.Abp.Identity.EntityFrameworkCore string userName = null, string phoneNumber = null, string emailAddress = null, + bool? isLockedOut = null, + bool? isActive = null, CancellationToken cancellationToken = default) { return await (await GetDbSetAsync()) @@ -159,6 +161,8 @@ namespace Volo.Abp.Identity.EntityFrameworkCore .WhereIf(!string.IsNullOrWhiteSpace(userName), x => 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(isActive == true, x => x.IsActive == isActive) .OrderBy(sorting.IsNullOrWhiteSpace() ? nameof(IdentityUser.UserName) : sorting) .PageBy(skipCount, maxResultCount) .ToListAsync(GetCancellationToken(cancellationToken)); @@ -202,6 +206,8 @@ namespace Volo.Abp.Identity.EntityFrameworkCore string userName = null, string phoneNumber = null, string emailAddress = null, + bool? isLockedOut = null, + bool? isActive = null, CancellationToken cancellationToken = default) { return await (await GetDbSetAsync()) @@ -219,6 +225,8 @@ namespace Volo.Abp.Identity.EntityFrameworkCore .WhereIf(!string.IsNullOrWhiteSpace(userName), x => 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(isActive == true, x => x.IsActive == isActive) .LongCountAsync(GetCancellationToken(cancellationToken)); } 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 318c0ae4ad..2800e42c18 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 @@ -143,6 +143,8 @@ namespace Volo.Abp.Identity.MongoDB string userName = null, string phoneNumber = null, string emailAddress = null, + bool? isLockedOut = null, + bool? isActive = null, CancellationToken cancellationToken = default) { return await (await GetMongoQueryableAsync(cancellationToken)) @@ -160,6 +162,8 @@ namespace Volo.Abp.Identity.MongoDB .WhereIf>(!string.IsNullOrWhiteSpace(userName), x => 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>(isActive == true, x => x.IsActive == isActive) .OrderBy(sorting.IsNullOrWhiteSpace() ? nameof(IdentityUser.UserName) : sorting) .As>() .PageBy>(skipCount, maxResultCount) @@ -210,6 +214,8 @@ namespace Volo.Abp.Identity.MongoDB string userName = null, string phoneNumber = null, string emailAddress = null, + bool? isLockedOut = null, + bool? isActive = null, CancellationToken cancellationToken = default) { return await (await GetMongoQueryableAsync(cancellationToken)) @@ -227,6 +233,8 @@ namespace Volo.Abp.Identity.MongoDB .WhereIf>(!string.IsNullOrWhiteSpace(userName), x => 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>(isActive == true, x => x.IsActive == isActive) .LongCountAsync(GetCancellationToken(cancellationToken)); } From 54d0864f2eb6ff61b64b2c9f1f4ed8153f99bc24 Mon Sep 17 00:00:00 2001 From: maliming Date: Tue, 2 Nov 2021 17:32:27 +0800 Subject: [PATCH 2/2] Rename `IsActive` to `NotActive`. --- .../Volo/Abp/Identity/IIdentityUserRepository.cs | 4 ++-- .../EntityFrameworkCore/EfCoreIdentityUserRepository.cs | 8 ++++---- .../Abp/Identity/MongoDB/MongoIdentityUserRepository.cs | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentityUserRepository.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentityUserRepository.cs index 8b871220dc..37516c05a7 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentityUserRepository.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentityUserRepository.cs @@ -62,7 +62,7 @@ namespace Volo.Abp.Identity string phoneNumber = null, string emailAddress = null, bool? isLockedOut = null, - bool? isActive = null, + bool? notActive = null, CancellationToken cancellationToken = default ); @@ -99,7 +99,7 @@ namespace Volo.Abp.Identity string phoneNumber = null, string emailAddress = null, bool? isLockedOut = null, - bool? isActive = null, + bool? notActive = null, CancellationToken cancellationToken = default ); } 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 77e9607cdf..648c999624 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 @@ -142,7 +142,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore string phoneNumber = null, string emailAddress = null, bool? isLockedOut = null, - bool? isActive = null, + bool? notActive = null, CancellationToken cancellationToken = default) { return await (await GetDbSetAsync()) @@ -162,7 +162,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore .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(isActive == true, x => x.IsActive == isActive) + .WhereIf(notActive == true, x => !x.IsActive) .OrderBy(sorting.IsNullOrWhiteSpace() ? nameof(IdentityUser.UserName) : sorting) .PageBy(skipCount, maxResultCount) .ToListAsync(GetCancellationToken(cancellationToken)); @@ -207,7 +207,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore string phoneNumber = null, string emailAddress = null, bool? isLockedOut = null, - bool? isActive = null, + bool? notActive = null, CancellationToken cancellationToken = default) { return await (await GetDbSetAsync()) @@ -226,7 +226,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore .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(isActive == true, x => x.IsActive == isActive) + .WhereIf(notActive == true, x => !x.IsActive) .LongCountAsync(GetCancellationToken(cancellationToken)); } 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 2800e42c18..30a8c147aa 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 @@ -144,7 +144,7 @@ namespace Volo.Abp.Identity.MongoDB string phoneNumber = null, string emailAddress = null, bool? isLockedOut = null, - bool? isActive = null, + bool? notActive = null, CancellationToken cancellationToken = default) { return await (await GetMongoQueryableAsync(cancellationToken)) @@ -163,7 +163,7 @@ namespace Volo.Abp.Identity.MongoDB .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>(isActive == true, x => x.IsActive == isActive) + .WhereIf>(notActive == true, x => !x.IsActive) .OrderBy(sorting.IsNullOrWhiteSpace() ? nameof(IdentityUser.UserName) : sorting) .As>() .PageBy>(skipCount, maxResultCount) @@ -215,7 +215,7 @@ namespace Volo.Abp.Identity.MongoDB string phoneNumber = null, string emailAddress = null, bool? isLockedOut = null, - bool? isActive = null, + bool? notActive = null, CancellationToken cancellationToken = default) { return await (await GetMongoQueryableAsync(cancellationToken)) @@ -234,7 +234,7 @@ namespace Volo.Abp.Identity.MongoDB .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>(isActive == true, x => x.IsActive == isActive) + .WhereIf>(notActive == true, x => !x.IsActive) .LongCountAsync(GetCancellationToken(cancellationToken)); }