Browse Source
Should not update user's `PhoneNumber ` if input's `PhoneNumber` is `NullOrWhiteSpace`.
pull/18833/head
maliming
3 years ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
2 changed files with
35 additions and
0 deletions
-
modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/ProfileAppService.cs
-
modules/account/test/Volo.Abp.Account.Application.Tests/Volo/Abp/Account/ProfileAppService_Tests.cs
|
|
|
@ -58,6 +58,11 @@ public class ProfileAppService : IdentityAppServiceBase, IProfileAppService |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (user.PhoneNumber.IsNullOrWhiteSpace() && input.PhoneNumber.IsNullOrWhiteSpace()) |
|
|
|
{ |
|
|
|
input.PhoneNumber = user.PhoneNumber; |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.Equals(user.PhoneNumber, input.PhoneNumber, StringComparison.InvariantCultureIgnoreCase)) |
|
|
|
{ |
|
|
|
(await UserManager.SetPhoneNumberAsync(user, input.PhoneNumber)).CheckErrors(); |
|
|
|
|
|
|
|
@ -73,6 +73,36 @@ public class ProfileAppService_Tests : AbpAccountApplicationTestBase |
|
|
|
result.Name.ShouldBe(input.Name); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task Should_Not_UpdatePhoneNumber_If_Input_PhoneNumber_IsNullOrWhiteSpace_Test() |
|
|
|
{ |
|
|
|
//Arrange
|
|
|
|
_currentUser.Id.Returns(_testData.UserJohnId); |
|
|
|
_currentUser.IsAuthenticated.Returns(true); |
|
|
|
|
|
|
|
//Act
|
|
|
|
var result = await _profileAppService.UpdateAsync(new UpdateProfileDto |
|
|
|
{ |
|
|
|
UserName = CreateRandomString(), |
|
|
|
Email = CreateRandomEmail(), |
|
|
|
PhoneNumber = "" |
|
|
|
}); |
|
|
|
|
|
|
|
//Assert
|
|
|
|
result.PhoneNumber.ShouldBe(null); |
|
|
|
|
|
|
|
//Act
|
|
|
|
result = await _profileAppService.UpdateAsync(new UpdateProfileDto |
|
|
|
{ |
|
|
|
UserName = CreateRandomString(), |
|
|
|
Email = CreateRandomEmail(), |
|
|
|
PhoneNumber = "123" |
|
|
|
}); |
|
|
|
|
|
|
|
//Assert
|
|
|
|
result.PhoneNumber.ShouldBe("123"); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task ChangePasswordAsync_FailsForSamePassword() |
|
|
|
{ |
|
|
|
|