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

Callback() private method

private Callback ( string returnUrl ) : System.Web.Mvc.ActionResult
returnUrl string
return System.Web.Mvc.ActionResult
        public ActionResult Callback(string returnUrl)
        {
            AuthenticationResult result = OAuthWebSecurity.VerifyAuthentication(Url.Action("Callback", new { ReturnUrl = returnUrl }));
            if (!result.IsSuccessful)
            {
                return RedirectToAction("Failure");
            }

            if (OAuthWebSecurity.Login(result.Provider, result.ProviderUserId, createPersistentCookie: false))
            {
                return RedirectToLocal(returnUrl);
            }

            if (User.Identity.IsAuthenticated)
            {
                // If the current user is logged in add the new account
                OAuthWebSecurity.CreateOrUpdateAccount(result.Provider, result.ProviderUserId, User.Identity.Name);
                return RedirectToLocal(returnUrl);
            }
            else
            {
                // User is new, ask for their desired membership name
                string loginData = OAuthWebSecurity.SerializeProviderUserId(result.Provider, result.ProviderUserId);
                var oAuthClientData = OAuthWebSecurity.GetOAuthClientData(result.Provider);
                ViewBag.ProviderDisplayName = oAuthClientData.DisplayName;
                ViewBag.ReturnUrl = returnUrl;
                return View("Confirmation", new RegisterExternalLoginModel { UserName = result.UserName, ExternalLoginData = loginData });
            }
        }