From 74c034e864d2d85bb418dfdcb0a40d545c98a5bf Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 18 Nov 2019 17:03:10 +0800 Subject: [PATCH] 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 b408828af0..795c8a6abc 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 @@ namespace Volo.Abp.Identity 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();