Skip to content

Commit

Permalink
Handling cases where Email and PhoneNumber have not changed.
Browse files Browse the repository at this point in the history
Resolve #2140
  • Loading branch information
maliming committed Nov 18, 2019
1 parent c09aecc commit 74c034e
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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))

This comment has been minimized.

Copy link
@gdlcf88

gdlcf88 Nov 19, 2019

Contributor

It will ignore null Email input when the admin want to set a user's email address to empty.

This comment has been minimized.

Copy link
@hikalkan

hikalkan Dec 13, 2019

Member

You're right. Created an issue: #2389

This comment has been minimized.

Copy link
@goxiaoy

goxiaoy Jan 15, 2020

Contributor

It's a liite bit confuse for the UpdateUserByInput function, If you want to keep the previous data by passing null or not passing it , you should consider Http Patch method instead of Http Post. As far as I see, CreateAsync or UpdateAsync in IdentityUserAppService would match to Post http api

This comment has been minimized.

Copy link
@hikalkan

hikalkan Jan 19, 2020

Member

CreateAsync uses post, UpdateAsync uses post. Update doesn't support partial update in current design.

{
(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();

Expand Down

0 comments on commit 74c034e

Please sign in to comment.