ArmedCards.Web.Controllers.AccountController.ExternalLoginCallback C# (CSharp) Method

ExternalLoginCallback() private method

private ExternalLoginCallback ( string returnUrl ) : System.Web.Mvc.ActionResult
returnUrl string
return System.Web.Mvc.ActionResult
        public ActionResult ExternalLoginCallback(string returnUrl)
        {
            Authentication.Results.AuthResult result = Authentication.OAuthSecurity.VerifyAuthentication(Url.Action("ExternalLoginCallback", new { ReturnUrl = returnUrl }));
			
			if (result.IsSuccessful)
			{
                if (Authentication.OAuthSecurity.Login(result.Provider, result.ProviderUserId, createPersistentCookie: false))
				{
                    if(result.ExtraData.ContainsKey("email"))
                    {
                        string key = string.Format("TempUserEmailAddress");

                        Session.Add(key, Library.Helpers.EncryptUtil.Encrypt(result.ExtraData["email"]));

                        return RedirectToAction("UpdatePicture", "Account", new { returnUrl = returnUrl });
                    }

					return RedirectToLocal(returnUrl);
				}

				if (!User.Identity.IsAuthenticated)
				{
					// User is new, ask for their desired membership name
                    string loginData = Authentication.OAuthSecurity.SerializeProviderUserId(result.Provider, result.ProviderUserId);

					Authentication.Models.Account.RegisterExternalLogin model = new Authentication.Models.Account.RegisterExternalLogin
					{
						UserName = "",
						ExternalLoginData = loginData,
                        ProviderDisplayName = Authentication.OAuthSecurity.GetOAuthClientDataDisplayName(result.Provider),
						ReturnUrl = returnUrl,
                        UserEmail = result.ExtraData["email"]
					};

					return View("ExternalLoginConfirmation", model);
				}
			}

            return RedirectToAction("ExternalLoginFailure");
        }