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?
Asked
Active
Viewed 252 times
1
-
You may call the function await FirebaseAuth.instance.signOut(); after the user is deleted. – Sowat Kheang May 29 '23 at 06:59
-
@SowatKheang It will only log out from one device. But I want to log out from all the devices on which the user is logged in with the same account. – Shehzad Raheem May 29 '23 at 07:04
-
The document does not mention anything regarding single-user sign-in. We have to manage it by ourselves, you may check [firebase-logout-user-all-sessions](https://stackoverflow.com/questions/54704253/firebase-logout-user-all-sessions) – Sowat Kheang May 29 '23 at 07:36
1 Answers
1
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.

Vishal Thakkar
- 652
- 4
- 18