同一用户登录Firebase身份验证限制 [英] Firebase authentication limit login by the same user
问题描述
Firebase中是否有一种方法可以限制同一用户同时登录的次数,我想对一个帐户同时设置3个设备的限制,我该如何实现呢?
is there a way in Firebase to limit the number of logins by the same user at the same time, says I want to put a limit of 3 devices at a time for one single account, how can I achieve that ?
推荐答案
Firebase不支持.最好的办法是跟踪令牌auth_time
.这是登录时间.您将为此保留3个条目的队列.每次登录用户时,发送其ID令牌以进行验证,将auth_time
添加到队列(如果尚不存在),并在队列中最旧的auth_time
超过最大大小时从队列中出队(3). ).您只允许访问该队列中具有auth_times的ID令牌的数据.
That is not supported by Firebase. The best you can do is keep track of the token auth_time
. This is the time of sign-in. You would keep a queue of 3 entries for that. Each time you sign-in a user, send their ID token for verification, add the auth_time
to the queue (if it is not there already) and dequeue the oldest auth_time
in the queue if it exceeds it maximum size (3) . You would only allow access to data for ID tokens with auth_times within that queue.
这篇关于同一用户登录Firebase身份验证限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!