如何才能安全地登录用户自动previous Facebook的身份验证后? [英] How can one securely log users in automatically after previous Facebook authentication?

查看:152
本文介绍了如何才能安全地登录用户自动previous Facebook的身份验证后?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用户抱怨他们不得不过于频繁登录。如果认证完全是建立在Facebook上的OAuth,如何才能将用户自动下一次登录,他们访问的页面?

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 visit the page?

示例用户流量:


  1. 用户点击登录与Facebook

  2. 用户与Facebook认证,并重定向回网站

  3. 用户确认并登录

  4. 用户关闭在现场窗口(而不是浏览器)

  5. 用户访问了几个小时后,并有重新授权给Facebook以获得再次的(用户抱怨这一点)

  1. User clicks "Login with Facebook"
  2. User authenticates with Facebook and is redirected back to site
  3. User is confirmed and logged in.
  4. User closes window on site (but not browser)
  5. User visits a few hours later and has to re-auth to Facebook to gain access again (users complain about this)

理想的用户流量


  • 的用户自动登录每次访问

  • 例外:如果用户点击注销,就应该要求他们访问重新授权下一次

  • Users are logged in automatically for each visit
  • Exception: If a user clicks "logout", it should require re-auth next time they visit.

如何才能做到这一点安全和可靠?

How can one do this safely and securely?

注:


  • 没有用户名或密码以往任何时候都存储在本地,只有本地用户标识及其相关的Facebook用户ID。

  • 脱机访问已经列入/授予在OAuth 2.0请求。

推荐答案

请使用JS-SDK的 FB.getLoginStatus()方法

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
  }
});

这篇关于如何才能安全地登录用户自动previous Facebook的身份验证后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆