How can one securely log users in automatically after previous Facebook authentication?

前端 未结 2 1383
萌比男神i
萌比男神i 2021-01-16 19:08

Users are complaining they have to login too frequently. If authentication is entirely built on Facebook OAuth, how can a user be logged in automatically the next time they

2条回答
  •  囚心锁ツ
    2021-01-16 19:22

    Make use of the JS-SDK FB.getLoginStatus() method:

    FB.getLoginStatus(function(response) {
      if (response.authResponse) {
        // logged in and connected user, someone you know
        // reload page or use ajax to update content of page
      } else {
        // no user session available, someone you dont know
      }
    });
    

提交回复
热议问题