From 74c034e864d2d85bb418dfdcb0a40d545c98a5bf Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 18 Nov 2019 17:03:10 +0800 Subject: [PATCH 1/2] Handling cases where Email and PhoneNumber have not changed. Resolve #2140 --- .../Volo/Abp/Identity/IdentityUserAppService.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs index b408828af0a..795c8a6abc9 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs @@ -127,8 +127,16 @@ await _userManager.FindByEmailAsync(email) private async Task UpdateUserByInput(IdentityUser user, IdentityUserCreateOrUpdateDtoBase input) { - (await _userManager.SetEmailAsync(user, input.Email)).CheckErrors(); - (await _userManager.SetPhoneNumberAsync(user, input.PhoneNumber)).CheckErrors(); + if (!input.Email.IsNullOrWhiteSpace() && !string.Equals(user.Email, input.Email, StringComparison.InvariantCultureIgnoreCase)) + { + (await _userManager.SetEmailAsync(user, input.Email)).CheckErrors(); + } + + if (!input.PhoneNumber.IsNullOrWhiteSpace() && !string.Equals(user.PhoneNumber, input.PhoneNumber, StringComparison.InvariantCultureIgnoreCase)) + { + (await _userManager.SetPhoneNumberAsync(user, input.PhoneNumber)).CheckErrors(); + } + (await _userManager.SetTwoFactorEnabledAsync(user, input.TwoFactorEnabled)).CheckErrors(); (await _userManager.SetLockoutEnabledAsync(user, input.LockoutEnabled)).CheckErrors(); From f09a93c3203a9578be315fca926a6ec8d658e6af Mon Sep 17 00:00:00 2001 From: maliming Date: Tue, 19 Nov 2019 13:52:42 +0800 Subject: [PATCH 2/2] Remove non-null filtering of input dto. --- .../Volo/Abp/Identity/IdentityUserAppService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs index 795c8a6abc9..c1d0f8f28b4 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs @@ -127,12 +127,12 @@ await _userManager.FindByEmailAsync(email) private async Task UpdateUserByInput(IdentityUser user, IdentityUserCreateOrUpdateDtoBase input) { - if (!input.Email.IsNullOrWhiteSpace() && !string.Equals(user.Email, input.Email, StringComparison.InvariantCultureIgnoreCase)) + if (!string.Equals(user.Email, input.Email, StringComparison.InvariantCultureIgnoreCase)) { (await _userManager.SetEmailAsync(user, input.Email)).CheckErrors(); } - if (!input.PhoneNumber.IsNullOrWhiteSpace() && !string.Equals(user.PhoneNumber, input.PhoneNumber, StringComparison.InvariantCultureIgnoreCase)) + if (!string.Equals(user.PhoneNumber, input.PhoneNumber, StringComparison.InvariantCultureIgnoreCase)) { (await _userManager.SetPhoneNumberAsync(user, input.PhoneNumber)).CheckErrors(); }