且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从Firebase的实时数据库中删除具有UID的用户?

更新时间:2023-12-01 22:10:34

要删除客户端上的用户登录帐户的链接,已经找到的链接是您要在客户端上执行的操作的唯一选择.通常出于安全原因,您希望将大多数操作保留在服务器上,例如用于帐户创建/删除之类的操作,而Firebase会强制执行此操作.仅当您最近登录时才能删除帐户,客户端无法开始删除旧的/随机的帐户.

The link you already found for deleting the user-login-account client-side is your only option if you want to keep the action on the client. Usually you want to keep most of the actions for things like account creation/deletion on the server for security reasons, and Firebase forces the issue. You can only delete your account if you were recently logged in, you can't have client-side start deleting old/random accounts.

更好的选择是创建自己的Cloud Function,以处理与删除用户有关的所有事情.您必须使用已经找到的管理SDK 为此...但是您可以让Cloud Function执行任意数量的操作-它必须从身份验证"标签中删除用户,并删除数据库中的匹配数据.

The better option is to create your own Cloud Function to handle everything related to deleting a user. You would have to use the Admin SDK that you already found for this... but you could have that Cloud Function perform as many actions as you want - it will have to delete the user from the Auth tab, and delete the matching data in the Database.