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

ExternalLoginConfirmation() private method

private ExternalLoginConfirmation ( Authentication model ) : System.Web.Mvc.ActionResult
model Authentication
return System.Web.Mvc.ActionResult
        public ActionResult ExternalLoginConfirmation(Authentication.Models.Account.RegisterExternalLogin model)
        {
            string provider = null;
            string providerUserId = null;

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

            if (ModelState.IsValid)
            {
                Entities.User user = new Entities.User 
                { 
                    DisplayName = model.UserName,
                    PictureUrl = String.Format("/Account/Image?hash={0}", HttpUtility.UrlEncode(Library.Helpers.EncryptUtil.Encrypt(CalculateMD5Hash(model.UserEmail))))
			    };

                // Insert name into the profile table
                _insertUser.Execute(user);

                // Check if user already exists
                if (user.UserId > 0)
                {
                    Authentication.OAuthSecurity.CreateOrUpdateAccount(provider, providerUserId, model.UserName);
                    Authentication.OAuthSecurity.Login(provider, providerUserId, createPersistentCookie: false);

                    return RedirectToLocal(model.ReturnUrl);
                }
                else
                {
                    ModelState.AddModelError("UserName", "User name already exists. Please enter a different user name.");
                }
            }

            return View(model);
        }