Example #1
0
     protected void Page_Load(object sender, EventArgs e)
     {
         //Get the consent URL for the specified offers.
         ConsentUrl = wll.GetConsentUrl(Offers);
         
         HttpRequest req = HttpContext.Current.Request;
         HttpCookie authCookie = req.Cookies[AuthCookie];
 
         // If the raw consent token has been cached in a site cookie, attempt to
         // process it and extract the consent token.
         if (authCookie != null)
         {
             string t = authCookie.Value;
             Token = wll.ProcessConsentToken(t);
             getContacts(Token.DelegationToken,Token.LocationID);
             if ((Token != null) && !Token.IsValid())
             {
                 Token = null;
             }
         }
     }
        protected void Page_Load(object sender, EventArgs e)
        {
            //Get the consent URL for the specified offers.
            try
            {
                ConsentUrl = wll.GetConsentUrl(Offers);

                var action = Request["action"];

                if (action == "delauth")
                {
                    //Attempt to extract the consent token from the response.
                    var token = wll.ProcessConsent(Request.Form);

                    var authCookie = new HttpCookie(AuthCookie);
                    // If a consent token is found, store it in the cookie and then
                    // redirect to the main page.
                    if (token != null)
                    {
                        authCookie.Value   = token.Token;
                        authCookie.Expires = PersistCookie;
                    }
                    else
                    {
                        authCookie.Expires = ExpireCookie;
                    }

                    Response.Cookies.Add(authCookie);
                    Response.Redirect(Request.GetUrlRewriter().OriginalString, true);
                }
                else
                {
                    var req        = HttpContext.Current.Request;
                    var authCookie = req.Cookies[AuthCookie];

                    // If the raw consent token has been cached in a site cookie, attempt to
                    // process it and extract the consent token.
                    if (authCookie != null)
                    {
                        var t = authCookie.Value;
                        Token = wll.ProcessConsentToken(t);
                        if ((Token != null) && !Token.IsValid())
                        {
                            Token = null;
                            Response.Redirect(ConsentUrl);
                        }
                        if (Token != null)
                        {
                            ProcessContacts();
                        }
                    }
                    else
                    {
                        Response.Redirect(ConsentUrl);
                    }
                }
            }
            catch (System.Threading.ThreadAbortException)
            {
            }
            catch (Exception ex)
            {
                SubmitError(ex.Message);
            }
        }
Example #3
0
 /// <summary>
 /// The first step of the login phase.
 /// </summary>
 /// <param name="session"> The current session. </param>
 /// <param name="Server"> The current server utility. </param>
 /// <returns> The string representing the url used to connect. </returns>
 public string StartLogin(HttpSessionState session, HttpServerUtility Server)
 {
     return(wll.GetConsentUrl("Contacts.View"));
 }
Example #4
0
 /// <summary>
 /// Step 1
 /// </summary>
 /// <returns>Authorization URL</returns>
 public string GetAuthorizationURL()
 {
     return(WindowsLiveLogin.GetConsentUrl("Contacts.Invite", string.Empty, WindowsLiveLogin.ReturnUrl));
 }