Firebase Auth,在用户注册之前获取用户UID [英] Firebase Auth, get a User UID before the user registers

查看:69
本文介绍了Firebase Auth,在用户注册之前获取用户UID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我们的应用开发邀请机制.将邀请新用户使用其电子邮件地址或电话号码.我想保留一些有关受邀请但未注册用户的记录.因此,我希望在注册之前拥有其Firebase Auth用户UID.这可能吗?也许使用Firebase Admin SDK?

I am developing an invitation mechanism to our app. New users will be invited with their e-mail addresses or their telephone numbers. I would like to keep some records about the invited but non-registered user. So, I want to have their Firebase Auth User UID before they even signed up. Is this possible? Maybe using Firebase Admin SDK?

我不想使用他们的电子邮件地址或电话号码来引用他们,因为UID感觉像是一个更好的标识符.但是,在注册之前不存在UID,对吗?

I don't want to use their e-mail addresses or telephone numbers to refer to them because UID feels like a better identifier. However, UID is not there before they sign up, right?

我们开玩笑地创建了一个用户并为他们生成了无密码的登录名,等等.但是我们所做的一切似乎都与用户的初始注册不符.如果我们能得到一个UID,让用户稍后注册,那就太好了.

We toyed with creating a user and generating a passwordless login for them, etc. But whatever we do seems to mess with the initial sign up of users. It would be great if we could just get a UID and let the user sign up later.

推荐答案

您无法创建用户帐户,然后让用户使用相同的UID注册".因此,您将不得不稍微不同地处理注册"流程.

You cannot create a user account, and then have the user "sign up" with the same UID. So you will have to handle your "sign up" flow a little differently.

此演示中,管理员创建用户帐户,然后邀请用户通过向他们发送验证码进行登录(跳至录像中的3:00分钟标记).然后,允许用户通过出示验证码登录并激活其帐户.

In this demo an administrator creates a user account, and then invites the user to sign in by sending them an authentication code (jump ahead to the 3:00 minute mark in the recording). Then the user is allowed to sign in and activate their account by presenting the authentication code.

您可以尝试构建类似的东西.例如,您可以为数据库中的每个新用户保存一个标志,然后在自定义注册操作中清除该标志.

You can try to build something similar. For example you can save a flag for each new user in the database, and then clear that flag in a custom sign up action.

这篇关于Firebase Auth,在用户注册之前获取用户UID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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