如何在不登录的情况下通过Firebase Auth创建新用户? [英] How can I create a new user via Firebase Auth without signing in?

查看:80
本文介绍了如何在不登录的情况下通过Firebase Auth创建新用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个企业应用程序,其中管理员创建了新用户(没有注册表单).我正在使用Firebase Auth,在许多方面都很棒,但是我遇到了一个用例问题.当您使用firebase.auth().createUserWithEmailAndPassword(email, password)时,由此创建的用户将自动登录.这显然在管理员创建用户帐户时不起作用.有什么办法可以避免这种行为?谢谢.

I'm working on an enterprise application in which administrators create new users (there is no sign-up form). I am using Firebase Auth, which is great in many ways, but I've come across a problem for my use case. When you use firebase.auth().createUserWithEmailAndPassword(email, password), the user thereby created is automatically signed in. This obviously won't work when an admin is creating the user accounts. Is there any way to avoid this behavior? Thanks.

推荐答案

这是 Cloud Functions)中创建用户,而不是在客户端创建用户.当您要添加新用户时,您可以让客户端呼叫您的端点.此 codelab 显示了如何使用Firebase Admin Auth SDK合并自定义声明.这与您要寻找的内容略有不同,但是可以帮助您朝正确的方向入手.

This is a good use case for the Firebase Admin SDKs. Instead of creating the user client-side, you create the user in a managed environment, like a server or Cloud Functions. You have the client make a call to your endpoint when you want to add a new user. This codelab shows how to incorporate custom claims using the Firebase Admin Auth SDK. This is a little different from what you're exactly looking for, but it can get you started in the right direction.

这篇关于如何在不登录的情况下通过Firebase Auth创建新用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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