使用Cloud Functions for Firebase获取匿名用户 [英] Get anonymous users with Cloud Functions for Firebase

本文介绍了使用Cloud Functions for Firebase获取匿名用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Cloud Functions在我的项目中管理数据库和身份验证.我按照示例 https://github.com/firebase/functions-samples/tree/master/delete-unused-accounts-cron 删除我应用中的非活动用户.我只想获取一段时间不活动的匿名用户.我不知道对身份工具包进行查询以仅过滤正确的工具包.有人帮忙吗?

I am using Cloud Functions to manage the database and the auth in my project. I followed the example https://github.com/firebase/functions-samples/tree/master/delete-unused-accounts-cron to delete inactive users in my app. I want to get only the anonymous users that were inactive for some time. I don't know to make the query to the identity toolkit to filter only the correct ones. Does anybody help?

谢谢!

推荐答案

您可以使用Admin SDK listUsers API列出所有用户,然后检查该帐户是否没有提供者数据(假设您不使用自定义身份验证) )/不发送电子邮件,并检查元数据lastSignInTime.但是,由于Firebase会话是不确定的,因此不能保证该帐户处于非活动状态: 列出用户: https://firebase.google.com/docs/auth /admin/manage-users#list_all_users

You can use the Admin SDK listUsers API to list all users and then inspect if the account has no provider data (assuming you don't use custom authentication)/no emails and inspect the metadata lastSignInTime. However, as Firebase sessions are indefinite, that does not guarantee the account is inactive: Listing users: https://firebase.google.com/docs/auth/admin/manage-users#list_all_users

包含上次登录时间的用户记录元数据: https://firebase.google.com/docs/reference/admin/node/admin.auth.UserRecord#metadata

User record metadata which contains last sign in time: https://firebase.google.com/docs/reference/admin/node/admin.auth.UserRecord#metadata

这篇关于使用Cloud Functions for Firebase获取匿名用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆