问题描述
有什么办法可以从firebase中获取特定的用户帐户,然后将其删除?
Is there a way I can get a specific user account from firebase and then delete it?
推荐答案
在使用客户端SDK进行Firebase身份验证时,您只能删除当前已登录的用户帐户.其他任何情况都将带来巨大的安全风险,因为它将允许您的应用程序的用户删除彼此的帐户.
When using the client-side SDKs for Firebase Authentication, you can only delete the user account that is currently signed in. Anything else would be a huge security risk, as it would allow users of your app to delete each other's account.
用于Firebase身份验证的Admin SDK旨在在受信任的环境中使用,例如您的开发计算机,您控制的服务器或Cloud Functions.因为它们在受信任的环境中运行,所以它们可以执行客户端SDK无法执行的某些操作.例如:通过仅知道用户帐户的UID删除用户帐户.
The Admin SDKs for Firebase Authentication are designed to be used in a trusted environment, such as your development machine, a server that you control, or Cloud Functions. Because they run in a trusted environment, they can perform certain operations that the client-side SDKs can't perform. Such as for example: deleting user accounts by simply knowing their UID.
下面是从Node.js删除用户的示例:
Here's an example of deleting a user from Node.js:
admin.auth().deleteUser(uid);
有关其他受支持语言的更多信息和示例,请参见使用管理SDK删除用户.
For more information and examples in the other supported languages, see the documentation for deleting a user with the Admin SDK.
这篇关于将用户从Firebase身份验证中删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!