Visual Studio - Generates a bunch of code for AspNet Identity, namely LoginController and ManageController. The ManageController has the following code:
[HttpGet, Route("Manage/LinkLoginCallback")] public async Task<ActionResult> LinkLoginCallback(string returnUrl) { ExternalLoginInfo loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync(XsrfKey, User.Identity.GetUserId()); ... var result = await UserManager.AddLoginAsync(User.Identity.GetUserId(), loginInfo.Login); if (result.Succeeded) { ... } }
The problem with this code is that UserManager.AddLoginAsync() throws an exception when an external login with an existing email address is added. However, this is apparently the correct scenario:
- A user subscribed to Google Plus via email: user-email@gmail.com
- The user used the same email address to subscribe to Facebook.
- Now they cannot βlinkβ both accounts under the same local account in my application due to this exception.
How do I handle this situation and add both accounts? Are there any problems with this?
source share