예제 #1
0
        public ActionResult CallBack(string type, string returnUrl)
        {
            var provider = LoginProviderFactory.Create(type);

            var user = provider.CallBack(Url.Action("CallBack", "Login", new { type }, "http"), Request.Params);

            if (!string.IsNullOrEmpty(returnUrl))
            {
                return(Redirect(returnUrl));
            }

            // Check if this is only a new mapping or a new login
            if (User.Identity.IsAuthenticated)
            {
                AddUserProfileLogin(user);
            }
            else
            {
                AddUserProfile(user);
                Response.Cookies.Add(new HttpCookie("gravatar", user.EmailAddress));
                Response.Cookies.Add(new HttpCookie("name", user.Name));
                FormsAuthentication.SetAuthCookie(user.ClaimedIdentifier, true);
            }

            return(RedirectToAction("Index", "Tasks"));
        }
예제 #2
0
        public ActionResult Login(string type, string returnUrl)
        {
            var provider = LoginProviderFactory.Create(type);

            // Keep returnUrl split for debugging purpose
            var providerUrl = provider.Login(Url.Action("CallBack", "Login", new { type }, "http"));

            // OpenId Provider sets the httpresponse manually
            if (providerUrl != null)
            {
                return(Redirect(providerUrl));
            }
            return(Content(""));
        }