duanpin2009 2013-11-25 09:59
浏览 190
已采纳

Facebook登录重定向问题

I have a site with a working Facebook login.

The problem is happens when the user comes to the site for the first time (or after clearing cookies).

The user flow is the following:

  1. User clicks "Sign Up with Facebook"
  2. User is redirected to Facebook authentication
  3. If User accepts, he/she is redirected to the 'Sign Up' page.

The problem is that if the person is doing this for the first time, they are always redirected back to the home page.

There are only 2 possible views that can be given for this url

  1. The Sign Up page, with only some form data sent as parameters
  2. An alert box upon successful DB persistence

Thus, I have ruled out PHP as a possible cause of the redirect.

I have included the JavaScript managing the Facebook interaction.

All other relevant code can be found in the HTML of the page.

The Page can be found at http://trioisrael.com

function fb_login(){
    FB.login(function(response) {

        if (response.authResponse) {
            window.location = "http://trioisrael.com/signup"
            //console.log(response); // dump complete info
            access_token = response.authResponse.accessToken; //get access token
            user_id = response.authResponse.userID; //get FB UID

            FB.api('/me', function(response) {
                user_email = response.email; //get user email
                // you can store this data into your database
            });

        } else {
            //user hit cancel button
            alert('We use facebook to make sure that everyone is really who they say they are');

        }
    }, {
        scope: 'user_photos,user_birthday'
    });
}
  • 写回答

1条回答 默认 最新

  • dsc7188 2013-11-25 11:19
    关注

    Trying to do additional stuff after assigning a new value to window.location (which should be window.location.href, of course) does not make sense.

    If you want to do additional stuff after login, do it before redirecting the user somewhere else.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)