예제 #1
0
    public void Page_Load(object sender, EventArgs e)
    {
        gridManage.OnGetDataSource += new EventHandler(gridManage_OnGetDataSource);
        if (!IsPostBack)
        {
            string facebookConnect = Request["connect"];
            if (!string.IsNullOrEmpty(facebookConnect))
            {
                FacebookPageManager facebook = new FacebookPageManager(SessionManager);
                SortedList<string, string> facebookCookies = facebook.GetFacebookCookies(HttpContext.Current.Request.Cookies);
                List<String> keys = new List<String>(facebookCookies.Keys);
                List<String> values = new List<String>(facebookCookies.Values);
                SessionManager.AccountService.CreateAccountFacebook(SessionManager.Ticket,
                    HttpContext.Current.Request.Cookies[facebook.FacebookAPIKey].Value, keys.ToArray(), values.ToArray());
                Redirect(Request.Path);
            }

            gridManage_OnGetDataSource(sender, e);
            gridManage.DataBind();

            SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute();
            sitemapdata.Add(new SiteMapDataAttributeNode("Me Me", Request, "AccountManage.aspx"));
            sitemapdata.Add(new SiteMapDataAttributeNode("Facebook", Request.Url));
            StackSiteMap(sitemapdata);
        }
    }
예제 #2
0
    public void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            FacebookPageManager facebook = new FacebookPageManager(SessionManager);
            if (string.IsNullOrEmpty(facebook.FacebookAPIKey))
            {
                throw new Exception("This site is not configured for Facebook login: missing Facebook API key.");
            }

            if (!facebook.HasFacebookCookies(HttpContext.Current.Request.Cookies))
            {
                Redirect(facebook.GetLoginUrl(Request.Url.ToString()));
            }

            SortedList <string, string> facebookCookies = facebook.GetFacebookCookies(HttpContext.Current.Request.Cookies);
            List <String> cookieNames  = new List <String>(facebookCookies.Keys);
            List <String> cookieValues = new List <String>(facebookCookies.Values);

            Facebook.Schema.user user = SessionManager.FacebookGraphService.GetUser(
                cookieNames.ToArray(), cookieValues.ToArray());

            facebookUser.SelectedObject                 = user;
            facebookUserStatus.SelectedObject           = user.status;
            facebookUserHometownLocation.SelectedObject = user.hometown_location;
            facebookUserCurrentLocation.SelectedObject  = user.current_location;
        }
    }
예제 #3
0
    public void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            FacebookPageManager facebook = new FacebookPageManager(SessionManager);
            if (string.IsNullOrEmpty(facebook.FacebookAPIKey))
            {
                throw new Exception("This site is not configured for Facebook login: missing Facebook API key.");
            }

            if (! facebook.HasFacebookCookies(HttpContext.Current.Request.Cookies))
            {
                Redirect(facebook.GetLoginUrl(Request.Url.ToString()));
            }

            SortedList<string, string> facebookCookies = facebook.GetFacebookCookies(HttpContext.Current.Request.Cookies);
            List<String> cookieNames = new List<String>(facebookCookies.Keys);
            List<String> cookieValues = new List<String>(facebookCookies.Values);

            Facebook.Schema.user user = SessionManager.FacebookGraphService.GetUser(
                cookieNames.ToArray(), cookieValues.ToArray());

            facebookUser.SelectedObject = user;
            facebookUserStatus.SelectedObject = user.status;
            facebookUserHometownLocation.SelectedObject = user.hometown_location;
            facebookUserCurrentLocation.SelectedObject = user.current_location;
        }
    }
예제 #4
0
    public void Page_Load(object sender, EventArgs e)
    {
        gridManage.OnGetDataSource += new EventHandler(gridManage_OnGetDataSource);
        if (!IsPostBack)
        {
            string facebookConnect = Request["connect"];
            if (!string.IsNullOrEmpty(facebookConnect))
            {
                FacebookPageManager         facebook        = new FacebookPageManager(SessionManager);
                SortedList <string, string> facebookCookies = facebook.GetFacebookCookies(HttpContext.Current.Request.Cookies);
                List <String> keys   = new List <String>(facebookCookies.Keys);
                List <String> values = new List <String>(facebookCookies.Values);
                SessionManager.AccountService.CreateAccountFacebook(SessionManager.Ticket,
                                                                    HttpContext.Current.Request.Cookies[facebook.FacebookAPIKey].Value, keys.ToArray(), values.ToArray());
                Redirect(Request.Path);
            }

            gridManage_OnGetDataSource(sender, e);
            gridManage.DataBind();

            SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute();
            sitemapdata.Add(new SiteMapDataAttributeNode("Me Me", Request, "AccountManage.aspx"));
            sitemapdata.Add(new SiteMapDataAttributeNode("Facebook", Request.Url));
            StackSiteMap(sitemapdata);
        }
    }
예제 #5
0
    public void Page_Load(object sender, EventArgs e)
    {
        try
        {
            PageManager.SetDefaultButton(loginLogin, Controls);

            if (!IsPostBack)
            {
                linkAdministrator.OnClientClick =
                    string.Format("location.href='mailto:{0}';",
                       SessionManager.GetCachedConfiguration(
                            "SnCore.Admin.EmailAddress", "*****@*****.**"));

                FacebookPageManager facebook = new FacebookPageManager(SessionManager);

                if (string.IsNullOrEmpty(facebook.FacebookAPIKey))
                {
                    panelFacebookLogin.Visible = false;
                    facebookLoginDisabled.Visible = true;
                }

                string openidmode = Request["openid.mode"];
                string openidtoken = SessionManager.OpenIdToken;
                if (!string.IsNullOrEmpty(openidmode) && !string.IsNullOrEmpty(openidtoken))
                {
                    NameValueCollectionSerializer serializer = new NameValueCollectionSerializer(Request.Params);
                    TransitOpenIdLogin t_login = SessionManager.AccountService.TryLoginOpenId(openidtoken, serializer.Names, serializer.Values);
                    if (!string.IsNullOrEmpty(t_login.Ticket))
                    {
                        SessionManager.Login(t_login.Ticket, SessionManager.RememberLogin);
                        Redirect(ReturnUrl);
                    }
                    else
                    {
                        Redirect(string.Format("AccountCreateOpenId.aspx?ReturnUrl={0}&ConsumerUrl={1}",
                            Renderer.UrlEncode(ReturnUrl), Renderer.UrlEncode(t_login.ConsumerUrl)));
                    }
                }

                string facebookConnect = Request["connect"];
                if (!string.IsNullOrEmpty(facebookConnect))
                {
                    SortedList<string, string> facebookCookies = facebook.GetFacebookCookies(HttpContext.Current.Request.Cookies);
                    List<String> keys = new List<String>(facebookCookies.Keys);
                    List<String> values = new List<String>(facebookCookies.Values);
                    TransitFacebookLogin t_login = SessionManager.AccountService.TryLoginFacebook(
                        HttpContext.Current.Request.Cookies[facebook.FacebookAPIKey].Value, keys.ToArray(), values.ToArray());

                    if (string.IsNullOrEmpty(t_login.Ticket))
                    {
                        Redirect("AccountCreateFacebook.aspx?connect=1");
                        return;
                    }

                    SessionManager.Login(t_login.Ticket, SessionManager.RememberLogin);
                    Redirect(ReturnUrl);
                }

                if (SessionManager.IsLoggedIn)
                {
                    ReportInfo("You're already logged-in. Click <a href='AccountManage.aspx'>here</a> to continue.", false);
                    loginLogin.Enabled = false;
                }
            }
        }
        catch
        {
            SessionManager.Logout();
            throw;
        }
    }
예제 #6
0
    public void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            FacebookPageManager facebook = new FacebookPageManager(SessionManager);
            if (string.IsNullOrEmpty(facebook.FacebookAPIKey))
            {
                throw new Exception("This site is not configured for Facebook login: missing Facebook API key.");
            }

            if (!string.IsNullOrEmpty(Request["betapassword"]))
                inputBetaPassword.Attributes["value"] = Request["betapassword"];

            panelBeta.Visible = SessionManager.AccountService.IsBetaPasswordSet();

            linkAdministrator.OnClientClick =
                string.Format("location.href='mailto:{0}';",
                   SessionManager.GetCachedConfiguration(
                        "SnCore.Admin.EmailAddress", "*****@*****.**"));

            string facebookConnect = Request["connect"];
            if (!string.IsNullOrEmpty(facebookConnect))
            {
                SortedList<string, string> facebookCookies = facebook.GetFacebookCookies(HttpContext.Current.Request.Cookies);
                List<String> keys = new List<String>(facebookCookies.Keys);
                List<String> values = new List<String>(facebookCookies.Values);
                TransitFacebookLogin t_login = SessionManager.AccountService.TryLoginFacebook(
                    HttpContext.Current.Request.Cookies[facebook.FacebookAPIKey].Value,
                    keys.ToArray(), values.ToArray());

                if (!string.IsNullOrEmpty(t_login.Ticket))
                {
                    ReportInfo(string.Format("An account for the Facebook user id \"{0}\" already exists." +
                        "<br />Please <a href='AccountLogin.aspx'>click here to log-in</a> instead.",
                        facebookCookies["user"]), false);

                    panelFacebook.Visible = false;
                    return;
                }

                int id = SessionManager.AccountService.CreateAccountWithFacebook(
                    inputBetaPassword.Text,
                    HttpContext.Current.Request.Cookies[facebook.FacebookAPIKey].Value,
                    keys.ToArray(),
                    values.ToArray());

                string ticket = ManagedAccount.GetTicketFromAccountId(id);
                SessionManager.Login(ticket, false);
                Redirect("AccountCreateWelcome.aspx");
                return;
            }
            else
            {
                panelFacebook.Visible = true;
            }

            if (SessionManager.IsLoggedIn)
            {
                ReportInfo("You're already logged-in. Click <a href='AccountManage.aspx'>here</a> to continue.");
                panelCreateFacebook.Enabled = false;
                return;
            }
        }
    }
예제 #7
0
    public void Page_Load(object sender, EventArgs e)
    {
        try
        {
            PageManager.SetDefaultButton(loginLogin, Controls);

            if (!IsPostBack)
            {
                linkAdministrator.OnClientClick =
                    string.Format("location.href='mailto:{0}';",
                                  SessionManager.GetCachedConfiguration(
                                      "SnCore.Admin.EmailAddress", "*****@*****.**"));

                FacebookPageManager facebook = new FacebookPageManager(SessionManager);

                if (string.IsNullOrEmpty(facebook.FacebookAPIKey))
                {
                    panelFacebookLogin.Visible    = false;
                    facebookLoginDisabled.Visible = true;
                }

                string openidmode  = Request["openid.mode"];
                string openidtoken = SessionManager.OpenIdToken;
                if (!string.IsNullOrEmpty(openidmode) && !string.IsNullOrEmpty(openidtoken))
                {
                    NameValueCollectionSerializer serializer = new NameValueCollectionSerializer(Request.Params);
                    TransitOpenIdLogin            t_login    = SessionManager.AccountService.TryLoginOpenId(openidtoken, serializer.Names, serializer.Values);
                    if (!string.IsNullOrEmpty(t_login.Ticket))
                    {
                        SessionManager.Login(t_login.Ticket, SessionManager.RememberLogin);
                        Redirect(ReturnUrl);
                    }
                    else
                    {
                        Redirect(string.Format("AccountCreateOpenId.aspx?ReturnUrl={0}&ConsumerUrl={1}",
                                               Renderer.UrlEncode(ReturnUrl), Renderer.UrlEncode(t_login.ConsumerUrl)));
                    }
                }

                string facebookConnect = Request["connect"];
                if (!string.IsNullOrEmpty(facebookConnect))
                {
                    SortedList <string, string> facebookCookies = facebook.GetFacebookCookies(HttpContext.Current.Request.Cookies);
                    List <String>        keys    = new List <String>(facebookCookies.Keys);
                    List <String>        values  = new List <String>(facebookCookies.Values);
                    TransitFacebookLogin t_login = SessionManager.AccountService.TryLoginFacebook(
                        HttpContext.Current.Request.Cookies[facebook.FacebookAPIKey].Value, keys.ToArray(), values.ToArray());

                    if (string.IsNullOrEmpty(t_login.Ticket))
                    {
                        Redirect("AccountCreateFacebook.aspx?connect=1");
                        return;
                    }

                    SessionManager.Login(t_login.Ticket, SessionManager.RememberLogin);
                    Redirect(ReturnUrl);
                }

                if (SessionManager.IsLoggedIn)
                {
                    ReportInfo("You're already logged-in. Click <a href='AccountManage.aspx'>here</a> to continue.", false);
                    loginLogin.Enabled = false;
                }
            }
        }
        catch
        {
            SessionManager.Logout();
            throw;
        }
    }
예제 #8
0
    public void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            FacebookPageManager facebook = new FacebookPageManager(SessionManager);
            if (string.IsNullOrEmpty(facebook.FacebookAPIKey))
            {
                throw new Exception("This site is not configured for Facebook login: missing Facebook API key.");
            }

            if (!string.IsNullOrEmpty(Request["betapassword"]))
            {
                inputBetaPassword.Attributes["value"] = Request["betapassword"];
            }

            panelBeta.Visible = SessionManager.AccountService.IsBetaPasswordSet();

            linkAdministrator.OnClientClick =
                string.Format("location.href='mailto:{0}';",
                              SessionManager.GetCachedConfiguration(
                                  "SnCore.Admin.EmailAddress", "*****@*****.**"));

            string facebookConnect = Request["connect"];
            if (!string.IsNullOrEmpty(facebookConnect))
            {
                SortedList <string, string> facebookCookies = facebook.GetFacebookCookies(HttpContext.Current.Request.Cookies);
                List <String>        keys    = new List <String>(facebookCookies.Keys);
                List <String>        values  = new List <String>(facebookCookies.Values);
                TransitFacebookLogin t_login = SessionManager.AccountService.TryLoginFacebook(
                    HttpContext.Current.Request.Cookies[facebook.FacebookAPIKey].Value,
                    keys.ToArray(), values.ToArray());

                if (!string.IsNullOrEmpty(t_login.Ticket))
                {
                    ReportInfo(string.Format("An account for the Facebook user id \"{0}\" already exists." +
                                             "<br />Please <a href='AccountLogin.aspx'>click here to log-in</a> instead.",
                                             facebookCookies["user"]), false);

                    panelFacebook.Visible = false;
                    return;
                }

                int id = SessionManager.AccountService.CreateAccountWithFacebook(
                    inputBetaPassword.Text,
                    HttpContext.Current.Request.Cookies[facebook.FacebookAPIKey].Value,
                    keys.ToArray(),
                    values.ToArray());

                string ticket = ManagedAccount.GetTicketFromAccountId(id);
                SessionManager.Login(ticket, false);
                Redirect("AccountCreateWelcome.aspx");
                return;
            }
            else
            {
                panelFacebook.Visible = true;
            }

            if (SessionManager.IsLoggedIn)
            {
                ReportInfo("You're already logged-in. Click <a href='AccountManage.aspx'>here</a> to continue.");
                panelCreateFacebook.Enabled = false;
                return;
            }
        }
    }