问题描述
我在我的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 functionsPlease visit this link for more details https://firebase.google.com/docs/auth/admin/manage-sessions#revoke_refresh_tokens
执行以下操作;
- 设置具有Firebase云功能的Web服务器(如果不存在)
- 使用管理员APK(这是此方法唯一可行的方法)-[访问此链接](( https://firebase.google.com/docs/admin/setup#initialize_the_sdk).
- 创建一个可接收uid并撤消上面第一个链接中指定的当前会话的api
- Set up web server with firebase cloud functions (if none exists)
- 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).
- 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注销用户所有会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!