示例#1
0
        private void ProcessProviderResult()
        {
            ProviderName = OpenAuth.GetProviderNameFromCurrentRequest();
            FedeFacebookClient.RewriteRequest();
            InstagramClient.RewriteRequest();
            GoogleOAuth2Client.RewriteRequest();

            var redirectUrl = "~/ExternalLogin.aspx";
            var returnUrl   = Request.QueryString["ReturnUrl"];

            if (!String.IsNullOrEmpty(returnUrl))
            {
                redirectUrl += "?ReturnUrl=" + HttpUtility.UrlEncode(returnUrl);
            }


            var authResult = OpenAuth.VerifyAuthentication(redirectUrl);

            if (!authResult.IsSuccessful)
            {
                Title = "External login failed";
                userNameForm.Visible = false;
                ModelState.AddModelError("Provider", String.Format("External login {0} failed.", ProviderDisplayName));

                Trace.Warn("OpenAuth", String.Format("There was an error verifying authentication with {0})", ProviderName), authResult.Error);
                return;
            }
            ProviderName       = authResult.Provider;
            ProviderUserId     = authResult.ProviderUserId;
            ProviderUserName   = authResult.UserName;
            Form.Action        = ResolveUrl(redirectUrl);
            imgSocial.ImageUrl = AuthHelper.GetSocialImage(authResult);
        }