Firebase注销用户所有会话 [英] Firebase logout user all sessions

查看:150
本文介绍了Firebase注销用户所有会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using Firebase authentication in my iOS app. Is there any way in Firebase when user login my app with Firebase then logout that user all other devices(sessions)? Can I do that with Firebase admin SDK?

推荐答案

当我遇到此问题时,我使用云功能解决了该问题 请访问此链接以获取更多详细信息 https://firebase.google.com/docs/auth/admin/manage-sessions#revoke_refresh_tokens

When i had this issue i resolved it with cloud functions Please visit this link for more details https://firebase.google.com/docs/auth/admin/manage-sessions#revoke_refresh_tokens

执行以下操作;

  1. 设置具有Firebase云功能的Web服务器(如果不存在)
  2. 使用管理员APK(这是​​此方法唯一可行的方法)-[访问此链接]( ( https://firebase.google.com/docs/admin/setup#initialize_the_sdk).
  3. 创建一个可接收uid并​​撤消上面第一个链接中指定的当前会话的api
  1. Set up web server with firebase cloud functions (if none exists)
  2. use the admin APK(thats the only way this method would work) - [Visit this link] ( (https://firebase.google.com/docs/admin/setup#initialize_the_sdk).
  3. Create an api that receives the uid and revokes current sessions as specified in the first link above

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

Voila用户已注销.我希望这能为解决问题提供真知灼见

Voila users logged out. I hope this gives insight into resolving the issue

这篇关于Firebase注销用户所有会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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