Skip to content

Commit

Permalink
fix: improve if declaration
Browse files Browse the repository at this point in the history
fix: restored check of the email value
  • Loading branch information
PiemP committed Jun 15, 2024
1 parent 5c378b8 commit f2faf17
Showing 1 changed file with 22 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -403,33 +403,36 @@ public async Task<IActionResult> ExternalLoginCallback(string returnUrl = null,
}
else
{
if (_identityOptions.User.RequireUniqueEmail)
var email = info.GetEmail();

if (_identityOptions.User.RequireUniqueEmail && !string.IsNullOrWhiteSpace(email))
{
iUser = await _userManager.FindByEmailAsync(info.GetEmail());
iUser = await _userManager.FindByEmailAsync(email);
}

ViewData["ReturnUrl"] = returnUrl;
ViewData["LoginProvider"] = info.LoginProvider;
ViewData["ReturnUrl"] = returnUrl;
ViewData["LoginProvider"] = info.LoginProvider;

if (iUser != null)
if (iUser != null)
{
if (iUser is User userToLink && registrationSettings.UsersMustValidateEmail && !userToLink.EmailConfirmed)
{
if (iUser is User userToLink && registrationSettings.UsersMustValidateEmail && !userToLink.EmailConfirmed)
{
return RedirectToAction(nameof(EmailConfirmationController.ConfirmEmailSent),
new
{
Area = UserConstants.Features.Users,
Controller = typeof(EmailConfirmationController).ControllerName(),
ReturnUrl = returnUrl,
});
}
return RedirectToAction(nameof(EmailConfirmationController.ConfirmEmailSent),
new
{
Area = UserConstants.Features.Users,
Controller = typeof(EmailConfirmationController).ControllerName(),
ReturnUrl = returnUrl,
});
}

// Link external login to an existing user
ViewData["UserName"] = iUser.UserName;
// Link external login to an existing user
ViewData["UserName"] = iUser.UserName;

return View(nameof(LinkExternalLogin));
}
return View(nameof(LinkExternalLogin));
}


// No user could be matched, check if a new user can register.
if (registrationSettings.UsersCanRegister == UserRegistrationType.NoRegistration)
{
Expand Down

0 comments on commit f2faf17

Please sign in to comment.