Firebase用户名/密码身份验证-一次仅允许一台设备登录 [英] Firebase Username/Password Authentication - allow only one device to sign-in at a time
问题描述
我在Android应用中使用Firebase用户名/密码身份验证.但这似乎允许任何数量的设备使用单个用户名/密码登录.有没有一种方法可以将登录限制在单个设备(或数量有限的少数设备)上?
I am using Firebase Username/Password authentication in my Android app. But it seems to allow any number of devices to sign in using a single username/password. Is there a way to limit sign-in to a single device (or a limited small number of devices)?
我正在寻找的是这样的东西.当新设备使用现有的用户名/密码登录时:
What I am looking for is something like this. When a new device signs-in using an existing username/password:
a) validate the username and password
b) sign-out all devices currently signed in with that username/password
c) then sign-in the new device
我看到了有关吊销刷新令牌的信息( https://firebase.google .com/docs/auth/admin/manage-sessions )-可以用来实现上述目标吗?
I saw something about revoking Refresh tokens (https://firebase.google.com/docs/auth/admin/manage-sessions) - can this be used to achieve the above?
或者,是否可以限制同时登录的次数?
Alternately, is there a way to limit the number of simultaneous logins?
现在我不使用任何数据库-希望使用不需要使用数据库的解决方案.
Right now I am NOT using any databases - would prefer a solution that does not require use of a database.
推荐答案
撤销刷新令牌
FirebaseAuth.getInstance().revokeRefreshTokens(uid);
撤销时,用户将注销,并提示重新进行身份验证.
On revocation, the user is signed out and prompted to reauthenticate.
这篇关于Firebase用户名/密码身份验证-一次仅允许一台设备登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!