英文:
Logout from all devices as user account deleted from firebase flutter
问题
我有应用程序的网页和移动版本。我在移动和网页上都使用相同的帐户登录。当我在移动设备上删除我的帐户时,我仍然可以在网页上执行所有操作。那么,当用户帐户被删除时,如何将用户从所有设备注销?
英文:
I have web and mobile versions of the app. I am logged in with the same account on mobile and the web. When I deleted my account on mobile, I was able to perform all the actions on the web. So, how can I log out the user from all the devices when the user account is deleted?
答案1
得分: 1
Firebase
没有提供这样的功能,但您可以按照以下方法操作。
_checkIfAccountIsDeleted() async {
try {
IdTokenResult? idTokenResult =
await FirebaseAuth.instance.currentUser?.getIdTokenResult(true);
if (idTokenResult == null || idTokenResult.token == null) {
print("用户已删除");
// FirebaseAuth.instance.signOut();
// 在这里执行注销操作...
} else {
print("用户可用");
}
} catch (er) {
print("用户已删除");
// FirebaseAuth.instance.signOut();
}
}
我已经检查过,在我的情况下它可以正常工作。
英文:
Firebase
does not provide such feature but you can follow the trick as below.
_checkIfAccountIsDeleted() async {
try {
IdTokenResult? idTokenResult =
await FirebaseAuth.instance.currentUser?.getIdTokenResult(true);
if (idTokenResult == null || idTokenResult.token == null) {
print("User is deleted");
// FirebaseAuth.instance.signOut();
// do logout stuff here...
} else {
print("User is available");
}
} catch (er) {
print("User is deleted");
// FirebaseAuth.instance.signOut();
}
}
I have checked it and it is working fine in my case.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论