Firebase authentication limit login by the same user

后端 未结 3 2139
感情败类
感情败类 2020-12-06 22:11

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

3条回答
  •  甜味超标
    2020-12-06 22:59

    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.

提交回复
热议问题