public void FacebookLogin()
 {
     fbWebContext = FacebookWebContext.Current; //get facebook session
     if (FacebookWebContext.Current.Session != null)
     {
         var app = new FacebookWebClient();
         var me = (IDictionary<string, object>)app.Get("me");   // get own information
         _FacebookUid = fbWebContext.UserId ;                // get own user id
         try
         {
             string fbName = (string)me["first_name"] + " " + (string)me["last_name"]; // get first name and last name
             if (OnFacebookLogin(fbName))
             {
                 SaveSessionInDB();
                 return;
             }
             else
             {
                 string notice = string.Format("<h2>Welcome, {0}.</h2>" +
                     "<h3>Login here to connect your Facebook login to your account<br/>" +
                     "Or sign-up to create full account, connected with your Facebook credentials</h3>", fbName);
             }
         }
         catch (Exception ex)
         {
         }
     }
 }
Пример #2
0
    public void BindData()
    {
        AppUser usr = ContextHelper.DataContext.User.First(o => o.UserId == SessionHelper.UserId);

        FacebookWebContext wc = new FacebookWebContext(GlobalObjects.FBApp);
        FacebookWebClient fb = new FacebookWebClient(wc);
        fb.AccessToken = usr.AccessToken;
        dynamic friends = fb.Get("/me/friends");

        List<string> userIds = new List<string>();
        foreach (dynamic friend in friends.data)
          userIds.Add(friend.id);

        if (userIds.Count() > 0)
        {
          DataTable dt = AppUserDao.GetUsersInfo(userIds);
          if (dt.Rows.Count > 0)
          {
        dlFriends.DataSource = dt;
        dlFriends.DataBind();
          }
          else
          {
        CommonFunctions.ShowInfo(lblStatus, "No friends found at timeflies");
          }
        }
        else
        {
          CommonFunctions.ShowInfo(lblStatus, "No friends found at timeflies");
        }
    }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FacebookWebClient"/> class.
        /// </summary>
        /// <param name="request">
        /// The request.
        /// </param>
        public FacebookWebClient(FacebookWebContext request)
        {
            Contract.Requires(request != null);

            Initialize(request);
            AccessToken = request.AccessToken;
        }
Пример #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FacebookWebClient"/> class.
        /// </summary>
        /// <param name="request">
        /// The request.
        /// </param>
        public FacebookWebClient(FacebookWebContext request)
        {
            Contract.Requires(request != null);

            Initialize(request);
            AccessToken = request.AccessToken;
        }
        public override void OnAuthorization(AuthorizationContext filterContext, IFacebookApplication settings)
        {
            var authorizer = new FacebookWebContext(settings, filterContext.HttpContext);

            if (!string.IsNullOrEmpty(Permissions) && Permissions.IndexOf(" ") != -1)
            {
                throw new ArgumentException("Permissions cannot contain whitespace.");
            }

            long? userId = (null != FacebookWebContext.Current.Session) ? (long?)FacebookWebContext.Current.Session.UserId : null;

            if (null == userId || !AuthorizedUsers.Contains(userId.Value))
            {
                if (!authorizer.IsAuthorized(ToArrayString(Permissions)))
                {
                    this.HandleUnauthorizedRequest(filterContext, FacebookApplication.Current);
                }
                else
                {
                    if (!AuthorizedUsers.Contains(FacebookWebContext.Current.Session.UserId))
                    {
                        AuthorizedUsers.Add(FacebookWebContext.Current.Session.UserId);
                    }
                }
            }
        }
Пример #6
0
        /// <summary>
        /// Check if the Facebook App has permissions from the specified user.
        /// </summary>
        /// <param name="context">
        /// The Facebook web context.
        /// </param>
        /// <param name="accessToken">
        /// The access token.
        /// </param>
        /// <param name="appId">
        /// The app id.
        /// </param>
        /// <param name="userId">
        /// The user id.
        /// </param>
        /// <param name="permissions">
        /// The list of permissions.
        /// </param>
        /// <returns>
        /// The list of permissions that are allowed from the specified permissions.
        /// </returns>
        internal static string[] HasPermissions(FacebookWebContext context, string accessToken, string appId, long userId, string[] permissions)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (string.IsNullOrEmpty(appId))
            {
                throw new ArgumentNullException("appId");
            }
            if (userId < 0)
            {
                throw new ArgumentOutOfRangeException("userId", "userId must be equal or greater than 0");
            }

            if (userId != 0 && !string.IsNullOrEmpty(accessToken))
            {
                try
                {
                    var fb = new FacebookWebClient(context)
                    {
                        AccessToken = accessToken
                    };
                    var remoteResult = ((IDictionary <string, object>)fb.Get("me/permissions"));
                    if (remoteResult != null && remoteResult.ContainsKey("data"))
                    {
                        var data = remoteResult["data"] as IList <object>;

                        if (data != null && data.Count > 0)
                        {
                            var permData = data[0] as IDictionary <string, object>;
                            if (permData == null)
                            {
                                return(new string[0]);
                            }
                            else
                            {
                                return((from perm in permData
                                        where perm.Value.ToString() == "1"
                                        select perm.Key).ToArray());
                            }
                        }
                    }
                }
                catch (FacebookOAuthException)
                {
                    return(null);
                }
            }

            return(null);
        }
Пример #7
0
        public override void OnAuthorization(AuthorizationContext filterContext, IFacebookApplication settings)
        {
            var authorizer = new FacebookWebContext(settings, filterContext.HttpContext);

            if (!string.IsNullOrEmpty(Permissions) && Permissions.IndexOf(" ") != -1)
            {
                throw new ArgumentException("Permissions cannot contain whitespace.");
            }

            if (!authorizer.IsAuthorized(ToArrayString(Permissions)))
            {
                this.HandleUnauthorizedRequest(filterContext, FacebookApplication.Current);
            }
        }
Пример #8
0
        /// <summary>
        /// Initializes the FacebookWebClient from <see cref="FacebookWebContext"/>.
        /// </summary>
        /// <param name="request">
        /// The request.
        /// </param>
        private void Initialize(FacebookWebContext request)
        {
            Contract.Requires(request != null);

            _request            = request;
            _isSecureConnection = request.IsSecureConnection;

            UseFacebookBeta = _request.Settings.UseFacebookBeta;

            if (request.HttpContext.Request.UrlReferrer != null && _request.HttpContext.Request.UrlReferrer.Host == "apps.beta.facebook.com")
            {
                UseFacebookBeta = true;
            }
        }
Пример #9
0
    public bool IsFbFriend(string videoUserId, string friendUserId)
    {
        AppUser usr = ContextHelper.DataContext.User.First(o => o.UserId == videoUserId);

        FacebookWebContext wc = new FacebookWebContext(GlobalObjects.FBApp);
        FacebookWebClient fb = new FacebookWebClient(wc);
        fb.AccessToken = usr.AccessToken;
        dynamic friends = fb.Get("/me/friends");

        List<string> userIds = new List<string>();
        foreach (dynamic friend in friends.data)
          userIds.Add(friend.id);

        return userIds.Contains(friendUserId);
    }
Пример #10
0
        /// <summary>
        /// Initializes the FacebookWebClient from <see cref="FacebookWebContext"/>.
        /// </summary>
        /// <param name="request">
        /// The request.
        /// </param>
        private void Initialize(FacebookWebContext request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            _request           = request;
            IsSecureConnection = _request.IsSecureConnection;

            UseFacebookBeta = _request.Settings.UseFacebookBeta;

            if (request.HttpContext.Request.UrlReferrer != null && _request.HttpContext.Request.UrlReferrer.Host == "apps.beta.facebook.com")
            {
                UseFacebookBeta = true;
            }
        }
Пример #11
0
        private static List<Images> GetFriendImages(string userToken, TimeFliesByEntities dc)
        {
            FacebookWebContext wc = new FacebookWebContext(GlobalObjects.FBApp);
              FacebookWebClient fb = new FacebookWebClient(wc);
              fb.AccessToken = userToken;
              dynamic friends = fb.Get("/me/friends");

              List<Images> images = new List<Images>();
              foreach (dynamic friend in friends.data)
              {
            string friendId = friend.id;
            Images image = dc.Images.Where(o => o.UserId == friendId).OrderByDescending(o => o.ImageId).FirstOrDefault();
            if (image != null)
              images.Add(image);
              }
              return images.OrderByDescending(o => o.DateAdded).Take(5).ToList();
        }
Пример #12
0
        //
        // GET: /Facebook/LogOn
        public ActionResult LogOn(string returnUrl)
        {
            var fbWebContext = new FacebookWebContext(FacebookApplication.Current, ControllerContext.HttpContext); // or FacebookWebContext.Current;

            if (fbWebContext.IsAuthorized(ExtendedPermissions.Split(',')))
            {
                if (!string.IsNullOrWhiteSpace(returnUrl))
                {
                    if (Url.IsLocalUrl(returnUrl))
                    {
                        return new RedirectResult(returnUrl);
                    }
                }

                return RedirectToAction("Index", "Home");
            }

            return View();
        }
Пример #13
0
        public string AuthenticateUser(string userId, string token)
        {
            try
              {
            using (TimeFliesByEntities dc = new TimeFliesByEntities(Settings.EFConnectionString))
            {
              string videoId = "id_";
              if (dc.User.Count(o => o.UserId == userId) > 0)
              {
            videoId += dc.Videos.First(o => o.UserId == userId).VideoId;
              }
              else // Add New User
              {
            FacebookWebContext wc = new FacebookWebContext(GlobalObjects.FBApp);
            FacebookWebClient fb = new FacebookWebClient(wc);
            fb.AccessToken = token;
            dynamic result = fb.Get("/me");
            string fbEmail = result.email ?? String.Empty;
            userId = result.id;
            videoId += RegisterUser(result.id, result.email, result.first_name + " " + result.last_name, token);

            /*
            const string username = "******";
            Person userData = FacebookSvc.GetUserData(token, username);
            string FQLquery = "https://api.facebook.com/method/fql.query?query=select%20email%20from%20user%20where%20uid%3D" + userData.id + "&access_token=" + token + "";
            string resp = new oAuthFacebook().WebRequest(oAuthFacebook.Method.GET, FQLquery, string.Empty);
            DataSet ds = new DataSet();
            StringReader xmlReader = new StringReader(resp);
            ds.ReadXml(xmlReader);
            string email = ds.Tables[1].Rows[0][0].ToString();
            videoId += RegisterUser(userData.id, email, userData.first_name + " " + userData.last_name, token);
             */
              }
              return videoId;
            }
              }
              catch (Exception ex)
              {
            EmailService.ErrorEmail(ex);
            return ex.Message;
              }
        }
Пример #14
0
    public void FacebookLogin()
    {
        fbwebContext = FacebookWebContext.Current;
        if (FacebookWebContext.Current.Session != null)
        {
            _FacebookUid = fbwebContext.UserId;
            try
            {
                var fbwc = new FacebookWebClient(FacebookWebContext.Current.AccessToken);
                var me = (IDictionary<string, object>)fbwc.Get("me");
                string fbName = (string)me["first_name"] + " " + (string)me["last_name"]; // get first name and last name
                if (OnFacebookLogin(fbName))
                {
                    SaveSessionInDB();
                    return;
                }
                else
                {
                    string notice = string.Format("<h2>Welcome, {0}.</h2>" +
                        "<h3>Login here to connect your Facebook login to your account<br/>" +
                        "Or sign-up to create full account, connected with your Facebook credentials</h3>", fbName);
                    if (Request.QueryString["ytfblink"] != null)
                    {

                    }
                    else
                    {

                    }
                }
            }
            catch (FacebookOAuthException ex)
            {

            }
        }
    }
Пример #15
0
 public FacebookWebAuthorizer(FacebookWebContext context)
 {
     _request = context;
 }
Пример #16
0
        public static void NewUserRegister(AppUser user, string videoId)
        {
            string body = "New User Register At TimeFlies <br>Username :"******" <br>Email:" + user.Email + "<br><br><a href=" + Settings.Url + "/" + videoId + ">Click here to view user's profile.</a><br>";

              FacebookWebContext wc = new FacebookWebContext(GlobalObjects.FBApp);
              FacebookWebClient fb = new FacebookWebClient(wc);
              fb.AccessToken = user.AccessToken;
              dynamic friends = fb.Get("/me/friends");

              List<string> userIds = new List<string>();
              foreach (dynamic friend in friends.data)
            userIds.Add(friend.id);

              IEnumerable<string> existingUserIds = ContextHelper.DataContext.Images.Where(o => userIds.Contains(o.UserId)).Select(o => o.UserId).Distinct().Take(3);

              if (existingUserIds.Count() > 0)
              {
            body += "Thanks<br>New user friend's at TimeFlies.by are:<br>";
            foreach (string userId in existingUserIds)
            {
              AppUser usrData = ContextHelper.DataContext.User.FirstOrDefault(o => o.UserId == userId);
              body += usrData.FullName + " (" + usrData.Email + ") " + "<br>";
            }
              }

              SendEmail(Settings.ContactEmailAddress, "New User Register At TimeFlies.by", body);
              //SendEmail("*****@*****.**", "New User Register At TimeFlies.by", body);
        }
Пример #17
0
        /// <summary>
        /// Initializes the FacebookWebClient from <see cref="FacebookWebContext"/>.
        /// </summary>
        /// <param name="request">
        /// The request.
        /// </param>
        private void Initialize(FacebookWebContext request)
        {
            Contract.Requires(request != null);

            _request = request;
            _isSecureConnection = request.IsSecureConnection;

            UseFacebookBeta = _request.Settings.UseFacebookBeta;

            if (request.HttpContext.Request.UrlReferrer != null && _request.HttpContext.Request.UrlReferrer.Host == "apps.beta.facebook.com")
            {
                UseFacebookBeta = true;
            }
        }
Пример #18
0
 public CanvasAuthorizer(FacebookWebContext context)
     : base(context)
 {
 }
Пример #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FacebookWebClient"/> class.
 /// </summary>
 /// <param name="request">
 /// The request.
 /// </param>
 public FacebookWebClient(FacebookWebContext request)
 {
     Initialize(request);
     AccessToken = request.AccessToken;
 }
Пример #20
0
 public CanvasAuthorizer(FacebookWebContext context)
     : base(context)
 {
 }
Пример #21
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //LHK: 3:59 PM 9/5/2011 - Wordpress topURL
        if (Request.QueryString["topurl"] != null)
        {
            _TopUrl = Request.QueryString["topurl"].ToString();
            Response.Cookies["topurl"].Value = _TopUrl;
            Response.Cookies["topurl"].Domain = "." + WebConfig.TopLevelDomain;
            Response.Cookies["topurl"].Expires = DateTime.Now.AddHours(4);
        }
        Response.AppendHeader("Pragma", "no-cache");
        Response.AppendHeader("Cache-Control", "no-cache");

        Response.CacheControl = "no-cache";
        Response.Expires = -1;

        Response.ExpiresAbsolute = new DateTime(1900, 1, 1);
        Response.Cache.SetCacheability(HttpCacheability.NoCache);

        Ajax.Utility.RegisterTypeForAjax(typeof(GuestBook_GuestBook));

        try
        {
            StringBuilder html = new StringBuilder();
            //imgAppLogo.Attributes.Add("onerror", "this.src='" + ResolveUrl("~/assets/images/bg_ProfilePhoto.gif") + "'");
            StateManager objStateManager = StateManager.Instance;
            //to get user id from session as user is logged in user
            objSessionValue = (SessionValue)objStateManager.Get("objSessionvalue", StateManager.State.Session);
            if (!Equals(objSessionValue, null))
            {
                _userId = objSessionValue.UserId;
                _userName = objSessionValue.FirstName == string.Empty ? objSessionValue.UserName : (objSessionValue.FirstName + " " + objSessionValue.LastName);
                if (FacebookWebContext.Current.Session != null)
                {
                    html.Append("<span style='cursor: default;' class='yt-Thumb' >");
                   // html.Append("<span style='border-bottom:solid 1px white ;border-right:solid 1px white ; width:58px;height:58px; '>");
                    html.Append("<fb:profile-pic uid=\"");
                    html.Append(FacebookWebContext.Current.UserId);
                    html.Append("\" size=\"square\" facebook-logo=\"true\"></fb:profile-pic></span>");
                    divImage.InnerHtml = html.ToString();

                }
                else
                {
                    string sImagePath = objSessionValue.UserImage != null && !string.IsNullOrEmpty(objSessionValue.UserImage.ToString()) ? objSessionValue.UserImage.ToString() : "";
                    if (!sImagePath.Equals(""))
                    {
                        if (!sImagePath.StartsWith("http://") && !sImagePath.StartsWith("https://"))
                        {
                            string[] virtualDir = CommonUtilities.GetPath();
                            if (virtualDir != null)
                            {
                                sImagePath = virtualDir[2] + sImagePath;  //+ Latest[i].VideoUrl
                            }
                        }

                        html.Append("<a class='yt-Thumb' style='cursor: default;' href='javascript:void(0);'> <img src='");
                        html.Append(sImagePath);
                        html.Append("' width='54' height='54'  /></a>");//class='yt-ItemPhoto'
                        divImage.InnerHtml = html.ToString();
                    }
                    else
                    {
                        //html.Append("<a class='yt-Thumb' style='cursor: default;' <img src='");
                        //html.Append(ResolveUrl("~/assets/images/bg_ProfilePhoto.gif"));
                        //html.Append("' width='50' height='50' class='yt-ItemPhoto' style='cursor: default;'  /></a>");
                        //divImage.InnerHtml = html.ToString();
                        html.Append("<a class='yt-Thumb' style='cursor: default;' href='javascript:void(0);'> <img src='");
                        html.Append(ResolveUrl("~/assets/images/bg_ProfilePhoto.gif"));
                        html.Append("' width='54' height='54'  /></a>");
                        divImage.InnerHtml = html.ToString();
                    }
                    //
                }

            }
            if (!this.IsPostBack)
            {
                //New code added for YT phase 4 to display Different divs accordi ngly ser is loggedin using FB/YT or not logged in

                if (_userId > 0)
                {
                    //New added to check wather user is connected with facebook
                    // UserType   0---> Not loggedin,  1--> YT logged in , 2--> FB logeed in

                    divAuthUser.Style.Add(HtmlTextWriterStyle.Display, "inline");
                    divUnAuthUser.Style.Add(HtmlTextWriterStyle.Display, "none");
                    //rfvUserName.Enabled = false;

                    FacebookWebContext fbwebcon = new FacebookWebContext();

                    if (fbwebcon.Session != null)
                    {
                        imgAppLogo.Src = ResolveUrl("~/assets/images/icon_Facebook.gif");
                        lblUserName.InnerHtml = "Logged in as " + _userName;

                    }
                    else
                    {
                        imgAppLogo.Src = ResolveUrl("~/assets/images/favicon.ico");
                        lblUserName.InnerHtml = "Logged in as " + _userName;
                    }

                }
                else
                {
                    divUnAuthUser.Style.Add(HtmlTextWriterStyle.Display, "inline");
                    divAuthUser.Style.Add(HtmlTextWriterStyle.Display, "none");

                    html.Append("<a class='yt-Thumb' style='cursor: default;' href='javascript:void(0);'> <img src='");
                    html.Append(ResolveUrl("~/assets/images/bg_ProfilePhoto.gif"));
                    html.Append("' width='54' height='54'  /></a>");
                    divImage.InnerHtml = html.ToString();

                    //html.Append("<img src='");
                    //html.Append(ResolveUrl("~/assets/images/bg_ProfilePhoto.gif"));
                    //html.Append("' width='50' height='50' />");
                    //divImage.InnerHtml = html.ToString();
                }
                // End

                objTribute = (Tributes)objStateManager.Get("TributeSession", StateManager.State.Session);

                if (Request.QueryString["mode"] != null || Request.QueryString["fbmode"] != null) //if user is coming through link
                {
                    if (Request.QueryString["TributeId"] != null)
                        _tributeId = int.Parse(Request.QueryString["TributeId"].ToString());

                    if (Request.QueryString["TributeName"] != null)
                        _tributeName = Request.QueryString["TributeName"].ToString();

                    if (Request.QueryString["TributeType"] != null)
                        _tributeType = Request.QueryString["TributeType"].ToString();

                    if (Request.QueryString["TributeUrl"] != null)
                        _tributeUrl = Request.QueryString["TributeUrl"].ToString();

                    //CreateTributeSession(); //to create the tribute session values if user comes o this page from link or from favorites list.
                }
                else if (!Equals(objTribute, null))
                {
                    _tributeId = objTribute.TributeId;
                    _tributeName = objTribute.TributeName;
                    _tributeType = objTribute.TypeDescription;
                    _tributeUrl = objTribute.TributeUrl;
                    _isActive = objTribute.IsActive;
                    _TributePackageType = objTribute.TributePackageType;

                }
                else
                    Response.Redirect(WebConfig.AppBaseDomain.ToString() + "Errors/Error404.aspx");
                    //Response.Redirect(Redirect.RedirectToPage(Redirect.PageList.Inner2LoginPage.ToString()), false);

                //AG: Added code for expiry message
                if (!Equals(_TributePackageType, null))
                {
                    if (_TributePackageType.Contains("Announce"))
                    {
                        ScriptManager.RegisterStartupScript(Page, this.GetType(), "a", "fnExpiryNoticePopupClose();", true);
                    }
                }

                //Start - Modification on 9-Dec-09 for the enhancement 3 of the Phase 1
                if (_tributeName != null) Page.Title = _tributeName + " | Guestbook";
                //End

                string tributeHome;
                if (TributesPortal.Utilities.WebConfig.ApplicationMode.Equals("local"))
                {
                    tributeHome = Session["APP_PATH"] + _tributeUrl;
                }
                else
                {
                    tributeHome = "http://" + _tributeType.Replace("New Baby", "newbaby").ToLower() + "." +
                        WebConfig.TopLevelDomain + "/" + _tributeUrl;
                }
                tributeHome += "/";
                _gbUrl = tributeHome + "GuestBook.aspx";
                if (TributesPortal.Utilities.WebConfig.ApplicationMode.Equals("local"))
                {
                    _gbUrl = _gbUrl + this.Master.query_string;
                    tributeHome = tributeHome + this.Master.query_string;
                }

                aTributeHome.HRef = tributeHome;
                gbWallTributeHome.Text = tributeHome;
                gbWallTributeHome1.Text = tributeHome;

                gbWallPostSubject.Text = string.Format("{0} added a guestbook message to the: {1} {2} Tribute", _userName, _tributeName, _tributeType);
                gbWallLink.Text = _gbUrl;
                gbWallLink1.Text = _gbUrl;
                gbWallTributeImage.Text = profile_prefix + objTribute.TributeImage;

                if (Session["TributeSession"] == null)
                    CreateTributeSession(); //to create the tribute session values if user comest o this page from link or from favorites list.

                //to get page size from config file
                intPageSize = (int.Parse(WebConfig.Pagesize_guestBook));

                //to get current page number, if user clicks on page number in paging it gets tha page number from query string
                //else page number is 1

                if (VwCurrentPage == 0)
                {
                    if (Request.QueryString["PageNo"] != null)
                        currentPage = int.Parse(Request.QueryString["PageNo"].ToString());
                    else
                        currentPage = 1;
                }
                else
                    currentPage = VwCurrentPage;

                //if user is coming to this page through a link in email gets the Tribute Id from the querystring
                //else Tribute id is to be picked from the session
                //if (Request.QueryString["TributeId"] != null)
                //{
                //    _tributeId = int.Parse(Request.QueryString["TributeId"].ToString());
                //}
                //else
                //{
                //    if (objStateManager.Get("TributeId", StateManager.State.Session) != null)
                //        _tributeId = int.Parse(objStateManager.Get("TributeId", StateManager.State.Session).ToString());
                //}

                UserIsAdmin(); //to check if user is tribute admin or not

                if (_tributeId > 0)
                {
                    //Response.Redirect(Redirect.RedirectToPage(Redirect.PageList.Inner2LoginPage.ToString()), false);

                    if (!this.IsPostBack)
                    {
                        // btnPost.Attributes["OnClick"] += ";return Validate_Comments();";

                        SetControlText(); //to set values to labels and buttons

                        txtMessage.Attributes.Add("onkeyup", "CheckGuestBookCommentLength();");

                        totalRecordCount = this._presenter.OnPaging(GetSessionObject(currentPage)); //to get total number of records
                        //this._presenter.OnViewLoaded();
                        this._presenter.OnViewInitialized(GetSessionObject(currentPage), _tributeName, _tributeType);
                        ControlsVisibility(); //to set controls visibility
                        // Page.SetFocus(txtMessage);

                        if (_userId == 0)
                        {
                            btnPost.Attributes.Add("onClick", "return setSessionMsg(); return false;");
                            // rfvMessage.Enabled = false;
                        }
                        else
                        {
                            btnPost.Attributes.Add("onClick", "return validateInput(); return false;");
                        }
                    }
                }
                else
                {
                    Response.Redirect(WebConfig.AppBaseDomain.ToString() + "Errors/Error404.aspx");
                }

                string nonLoggedIn = Request.QueryString["GuestBook_without_login"];

                if (Session["CommentsSession"] != null && !string.IsNullOrEmpty(Session["CommentsSession"].ToString()))
                {

                    // code here for save
                    ArrayList _arrNew = (ArrayList)Session["CommentsSession"];
                    if (_arrNew != null && _arrNew.Count == 2)
                    {
                        txtMessage.Text = _arrNew[1].ToString();
                        txtUserName.Text = _arrNew[0].ToString();
                    }
                    if ((nonLoggedIn == "true")||(_userId > 0))
                    {
                        if (!txtMessage.Text.Trim().ToLower().Equals("message") && !txtUserName.Text.ToLower().Equals("name") && !txtMessage.Text.Trim().Equals("") && !txtUserName.Text.Trim().Equals("")) //
                        {
                            BtnClick_deligate _objBtnClickDeligate = new BtnClick_deligate(btnPost_Click);
                            object o = new object();
                            EventArgs obje = new EventArgs();
                            _objBtnClickDeligate(o, obje);
                        }
                    }
                    Session.Remove("CommentsSession");
                    txtMessage.Text = "Message";
                    txtUserName.Text = "Name";
                }

            }

        }
        catch (Exception ex)
        {
            Response.Redirect(WebConfig.AppBaseDomain.ToString() + "Errors/Error404.aspx");
        }
    }
Пример #22
0
 public FacebookWebAuthorizer(IFacebookApplication settings, HttpContextBase httpContext)
 {
     _request = new FacebookWebContext(settings, httpContext);
 }
Пример #23
0
    private AppUser LoginFacebook(string accessToken)
    {
        FacebookWebContext wc = new FacebookWebContext(GlobalObjects.FBApp);
        FacebookWebClient fb = new FacebookWebClient(wc);
        fb.AccessToken = accessToken;
        dynamic result = fb.Get("/me");
        string fbEmail = result.email ?? String.Empty;
        if (string.IsNullOrEmpty(fbEmail))
        {
          ShowErr("Getting data from Facebook failed. Please try again after 3-5 minutes.");
          return null;
        }
        string userId = result.id;
        AppUser usr = ContextHelper.DataContext.User.FirstOrDefault(o => o.UserId == userId);

        if (usr == null)
          usr = RegisterUser(result.id, result.email, result.first_name + " " + result.last_name, accessToken);
        else
        {
          usr.LastLogin = DateTime.Now;
          usr.AccessToken = accessToken;// result.Token;
          usr.FullName = result.first_name + " " + result.last_name;
          ContextHelper.DataContext.SaveChanges();

          ScriptManager.RegisterStartupScript(this, this.GetType(), "MyScript", "window.opener.FBCalback();window.close ();", true);
        }
        return usr;
    }
Пример #24
0
 public FacebookWebAuthorizer(IFacebookApplication settings, HttpContextBase httpContext)
 {
     _request = new FacebookWebContext(settings, httpContext);
 }
Пример #25
0
 public FacebookWebAuthorizer(FacebookWebContext context)
 {
     _request = context;
 }