Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // if this is a callback that is providing the twitter access token, then update with the token.
        if (!String.IsNullOrEmpty(Request["oauth_token"]) && Page.User.Identity.IsAuthenticated)
        {
            if (String.IsNullOrEmpty(Request["oauth_verifier"]))
            {
                throw new MyFlightbookException("oauth token passed but no oauth_verifier along with it.");
            }

            oAuthTwitter oAuth = new oAuthTwitter();
            oAuth.AccessTokenGet(Request["oauth_token"], Request["oauth_verifier"]);
            mfbTwitter.SetUserTwitterToken(Page.User.Identity.Name, oAuth);
        }


        if (util.GetStringParam(Request, "oauth_token").Length > 0)
        {
            LogbookEntry le = mfbTwitter.PendingFlightToPost;
            if (le != null)
            {
                mfbTwitter.PostFlight(le);
                mfbTwitter.PendingFlightToPost = null; // clear it
            }
        }

        Response.Redirect(SocialNetworkAuthorization.PopRedirect(Master.IsMobileSession() ? SocialNetworkAuthorization.DefaultRedirPageMini : SocialNetworkAuthorization.DefaultRedirPage));
    }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string szCode = util.GetStringParam(Request, "code");

        if (!String.IsNullOrEmpty(szCode))
        {
            Profile pf = MyFlightbook.Profile.GetUser(Page.User.Identity.Name);
            pf.GooglePlusAccessToken = szCode;
            pf.FCommit();
        }

        Response.Redirect(SocialNetworkAuthorization.PopRedirect(Master.IsMobileSession() ? SocialNetworkAuthorization.DefaultRedirPageMini : SocialNetworkAuthorization.DefaultRedirPage));
    }
Ejemplo n.º 3
0
 protected void lnkAuthorizeGooglePlus_Click(object sender, EventArgs e)
 {
     try
     {
         SocialNetworkAuthorization.PushRedirect(Request.Url.PathAndQuery);
         Response.Redirect(mfbGooglePlus1.AuthURL.ToString());
     }
     catch (MyFlightbookException ex)
     {
         lblSocNetworkPrefsUpdated.Text     = ex.Message;
         lblSocNetworkPrefsUpdated.CssClass = "error";
     }
 }
Ejemplo n.º 4
0
 protected void FlightUpdated(object sender, EventArgs e)
 {
     // if we had been editing a flight do a redirect so we have a clean URL
     // OR if there are pending redirects, do them.
     // Otherwise, just clean the page.
     if (Request[szParamIDFlight] != null || SocialNetworkAuthorization.RedirectList.Count > 0)
     {
         Response.Redirect(SocialNetworkAuthorization.PopRedirect(Master.IsMobileSession() ? SocialNetworkAuthorization.DefaultRedirPageMini : "~/Member/LogbookNew.aspx"));
     }
     else
     {
         Response.Redirect("~/Member/Logbook.aspx", true);
     }
 }
Ejemplo n.º 5
0
    protected void mfbEditFlight1_FlightUpdated(object sender, LogbookEventArgs e)
    {
        if (e == null)
        {
            throw new ArgumentNullException("e");
        }

        // if we had been editing a flight do a redirect so we have a clean URL
        // OR if there are pending redirects, do them.
        // Otherwise, just clean the page.
        if (Request[szParamIDFlight] != null || SocialNetworkAuthorization.RedirectList.Count > 0)
        {
            Response.Redirect(SocialNetworkAuthorization.PopRedirect(Master.IsMobileSession() ? SocialNetworkAuthorization.DefaultRedirPageMini : SocialNetworkAuthorization.DefaultRedirPage));
        }
        else if (e.IDNextFlight != LogbookEntry.idFlightNone)
        {
            Response.Redirect(String.Format(CultureInfo.InvariantCulture, "~/Member/LogbookNew.aspx/{0}{1}", e.IDNextFlight, Request.Url.Query), true);
        }
        else
        {
            Response.Redirect(String.Format(CultureInfo.InvariantCulture, "~/Member/LogbookNew.aspx{0}", Request.Url.Query), true);
        }
    }
Ejemplo n.º 6
0
    private void HandleOAuthRedirect()
    {
        if (!String.IsNullOrEmpty(Request.Params[szParamDropboxAuth])) // redirect from Dropbox oAuth request.
        {
            m_pf.DropboxAccessToken = new MFBDropbox().ConvertToken(Request).AccessToken;
            m_pf.FCommit();

            Response.Redirect(String.Format(CultureInfo.InvariantCulture, "{0}?pane=backup", Request.Path));
        }
        if (!String.IsNullOrEmpty(Request.Params[szParamGDriveAuth])) // redirect from GDrive oAuth request.
        {
            m_pf.GoogleDriveAccessToken = new GoogleDrive().ConvertToken(Request);
            m_pf.FCommit();

            Response.Redirect(String.Format(CultureInfo.InvariantCulture, "{0}?pane=backup", Request.Path));
        }
        if (!String.IsNullOrEmpty(Request.Params[szParam1DriveAuth])) // redirect from OneDrive oAuth request.
        {
            m_pf.OneDriveAccessToken = (DotNetOpenAuth.OAuth2.AuthorizationState)Session[OneDrive.TokenSessionKey];
            m_pf.FCommit();

            Response.Redirect(String.Format(CultureInfo.InvariantCulture, "{0}?pane=backup", Request.Path));
        }
        if (!String.IsNullOrEmpty(Request.Params[MFBFacebook.OAuthParam]))   // redirect from FB oAuth request
        {
            try
            {
                m_pf.FacebookAccessToken = MFBFacebook.ConvertToken(Request);
                m_pf.FCommit();
                mfbFacebook1.PostPendingFlight();
            }
            catch (MyFlightbookException) { }

            Response.Redirect(SocialNetworkAuthorization.PopRedirect(String.Format(CultureInfo.InvariantCulture, "{0}?pane=social", Request.Path)));
        }
    }
Ejemplo n.º 7
0
    /// <summary>
    /// Post the flight to Twitter
    /// </summary>
    /// <param name="le">The logbook entry being posted</param>
    /// <returns>true for success</returns>
    public Boolean PostFlight(LogbookEntry le)
    {
        if (le == null)
        {
            throw new ArgumentNullException("le");
        }
        Boolean fResult = false;

        oAuthTwitter oAuth = new oAuthTwitter();

        GetUserTwitterToken(le.User, oAuth);

        if (oAuth.Token.Length == 0 && Request["oauth_token"] == null)
        {
            PendingFlightToPost = le;  // hold on to this logbook entry for post-authorization...

            //Redirect the user to Twitter for authorization.
            oAuth.CallBackUrl = "~/member/PostFlight.aspx".ToAbsoluteURL(Request).ToString();
            SocialNetworkAuthorization.PushRedirect(oAuth.AuthorizationLinkGet());
        }
        else
        {
            if (oAuth.TokenSecret.Length == 0)
            {
                oAuth.AccessTokenGet(Request["oauth_token"], Request["oauth_verifier"]);
                SetUserTwitterToken(Page.User.Identity.Name, oAuth);
            }

            if (new TwitterPoster().PostToSocialMedia(le, Page.User.Identity.Name, Request.Url.Host))
            {
                FDefaultTwitterCheckboxState = true;
                fResult = true;
            }
        }
        return(fResult);
    }
Ejemplo n.º 8
0
 protected void EnteredFlight(object sender, EventArgs e)
 {
     Response.Redirect(SocialNetworkAuthorization.PopRedirect(SocialNetworkAuthorization.DefaultRedirPage));
 }
Ejemplo n.º 9
0
 protected void lnkSetUpFacebook_Click(object sender, EventArgs e)
 {
     SocialNetworkAuthorization.PushRedirect(Request.Url.PathAndQuery);
     MFBFacebook.Authorize();
 }
Ejemplo n.º 10
0
 protected void lnkSetUpTwitter_Click(object sender, EventArgs e)
 {
     SocialNetworkAuthorization.PushRedirect(Request.Url.PathAndQuery);
     Response.Redirect(mfbTwitter.AuthURL.ToString());
 }