Firebase 注销用户所有会话

2024-03-07

我在我的 iOS 应用程序中使用 Firebase 身份验证。当用户使用 Firebase 登录我的应用程序然后注销该用户的所有其他设备(会话)时,Firebase 有什么方法吗?我可以使用 Firebase 管理 SDK 来做到这一点吗?


当我遇到这个问题时,我用云功能解决了它 请访问此链接了解更多详情https://firebase.google.com/docs/auth/admin/manage-sessions#revoke_refresh_tokens https://firebase.google.com/docs/auth/admin/manage-sessions#revoke_refresh_tokens

请执行下列操作;

  1. 使用 firebase 云功能设置 Web 服务器(如果不存在)
  2. 使用管理 sdk(这是此方法有效的唯一方法)- [访问此链接]( (https://firebase.google.com/docs/admin/setup#initialize_the_sdk https://firebase.google.com/docs/admin/setup#initialize_the_sdk).
  3. 创建一个接收 uid 并撤销当前会话的 api,如上面第一个链接中指定的那样
  admin.auth().revokeRefreshTokens(uid)
    .then(() => {
      return admin.auth().getUser(uid);
    })
    .then((userRecord) => {
      return new Date(userRecord.tokensValidAfterTime).getTime() / 1000;
    })
    .then((timestamp) => {
      //return valid response to ios app to continue the user's login process
  });

瞧,用户已注销。我希望这能让您深入了解解决问题

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Firebase 注销用户所有会话 的相关文章

随机推荐