2

我正在使用 Facebook Auth,如果用户未登录或他们没有授权我的应用程序,我正在尝试添加从内部页面到登录页面的自动重定向,并且该部分工作正常。我遇到的问题是,当您到达 index.php 时,它会再次将您重定向到 index.php,并且无限次。我已经尝试了很多东西,比如 if (location.href == "index.php") 什么都不做,否则重定向,但我尝试的任何方法都不起作用。

FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
    var uid = response.authResponse.userID;
    var accessToken = response.authResponse.accessToken;
  } else if (response.status === 'not_authorized') {
    window.location = "index.php";
  } else {
    window.location = "index.php";
  }
});
4

0 回答 0