App.Web.Areas.Account.Controllers.ExternalLoginController.Confirmation C# (CSharp) Method

Confirmation() private method

private Confirmation ( RegisterExternalLoginModel model, string returnUrl ) : System.Web.Mvc.ActionResult
model App.Web.Areas.Account.Models.RegisterExternalLoginModel
returnUrl string
return System.Web.Mvc.ActionResult
        public ActionResult Confirmation(RegisterExternalLoginModel model, string returnUrl)
        {
            string provider = null;
            string providerUserId = null;

            if (User.Identity.IsAuthenticated || !OAuthWebSecurity.TryDeserializeProviderUserId(model.ExternalLoginData, out provider, out providerUserId))
            {
                return RedirectToAction("Manage");
            }

            if (ModelState.IsValid)
            {
                var userName = provider + "_" + providerUserId;
                var userProfile = this.usersService.GetUserProfile(userName);
                if (userProfile == null)
                {
                    userProfile = new UserProfile { UserName = provider + "_" + providerUserId, DisplayName = model.UserName };
                    this.usersService.Save(userProfile);
                }

                OAuthWebSecurity.CreateOrUpdateAccount(provider, providerUserId, userProfile.UserName);

                OAuthWebSecurity.Login(provider, providerUserId, createPersistentCookie: false);

                return RedirectToLocal(returnUrl);
            }

            ViewBag.ProviderDisplayName = OAuthWebSecurity.GetOAuthClientData(provider).DisplayName;
            ViewBag.ReturnUrl = returnUrl;
            return View(model);
        }