public virtual async Task <ActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl) { if (User.Identity.IsAuthenticated) { return(RedirectToAction(MVC.Account.Manage())); } if (ModelState.IsValid) { // Get the information about the user from the external login provider var info = await _authenticationManager.GetExternalLoginInfoAsync(); if (info == null) { return(View(MVC.Account.Views.ExternalLoginFailure)); } var user = new ApplicationUser() { UserName = model.UserName }; var result = await _securityManager.CreateAsync(user); if (result.Succeeded) { result = await _securityManager.AddLoginAsync(user.Id, info.Login); if (result.Succeeded) { await ServiceLocator.Instance.Resolve <IAuthenticationProvider>(new DependencyOverride(typeof(IAuthenticationManager), _authenticationManager)).SignInAsync(user, isPersistent: false); return(RedirectToLocal(returnUrl)); } } AddErrors(result); } ViewBag.ReturnUrl = returnUrl; return(View(model)); }