public async Task <IActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl = null) { if (User.IsSignedIn()) { return(View("ExternalSigninSuccess")); } if (ModelState.IsValid) { var info = await _signInManager.GetExternalLoginInfoAsync(); if (info == null) { return(View("Error")); } var user = new ApplicationUser { UserName = model.Username, Battletag = info.ExternalPrincipal.GetBattletag(), Email = model.Email, ProfileImage = await _imageManager.GetDefaultImageAsync(Defaults.ProfileImage), HeaderImage = await _imageManager.GetDefaultImageAsync(Defaults.HeaderImage) }; var result = await _userManager.CreateAsync(user); if (result.Succeeded) { // Create a player for this user var player = await _playerManager.CreatePlayerForUserAsync(user); var innerResult = await _userManager.AddLoginAsync(user, info); if (innerResult.Succeeded) { await _signInManager.SignInAsync(user, false); return(RedirectToAction(nameof(ExternalSigninSuccess), new { ReturnUrl = returnUrl })); } AddErrors(innerResult); } AddErrors(result); } ViewData["ReturnUrl"] = returnUrl; return(View(model)); }