Skip to content

Commit

Permalink
Fix User Registration (#16621)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeAlhayek authored Aug 26, 2024
1 parent dc69322 commit 8221b22
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ public override async Task<IDisplayResult> UpdateAsync(RegisterUserForm model, U

await context.Updater.TryUpdateModelAsync(vm, Prefix);

if (await _userManager.FindByNameAsync(vm.UserName) != null)
if (!string.IsNullOrEmpty(vm.UserName) && await _userManager.FindByNameAsync(vm.UserName) != null)
{
context.Updater.ModelState.AddModelError(Prefix, nameof(vm.UserName), S["A user with the same username already exists."]);
}
else if (_identityOptions.User.RequireUniqueEmail && await _userManager.FindByEmailAsync(vm.Email) != null)
else if (_identityOptions.User.RequireUniqueEmail && !string.IsNullOrEmpty(vm.Email) && await _userManager.FindByEmailAsync(vm.Email) != null)
{
context.Updater.ModelState.AddModelError(Prefix, nameof(vm.Email), S["A user with the same email address already exists."]);
}
Expand Down

0 comments on commit 8221b22

Please sign in to comment.