Firebase为同一用户生成两个不同的UID?
目前正在研究一个利用Firebase存储用户的React项目。为了使用户使用CreateUserWitheMailandPassword()。当用户在firebase中创建用户时,它将用户存储在看起来像-n4xrz的ID下...
但是,当我打电话以获取用户的UID(通过usercredential.user.uid)时,它会返回更长的一个这看起来像是Firebase生成的典型UID,并且与用户的父ID并不相同。关于这可能是什么想法?
Currently working on a React project that utilizes Firebase to store users. To make the user, I use createUserWithEmailAndPassword(). When the user is created in Firebase, it stores the user under an id that looks like -N4xrZ...
However, when I make a call to get the user's UID (through userCredential.user.uid), it returns a much longer one that looks like a typical UID generated by Firebase and that isn't the same as the user's parent id. Any ideas as to what this may be?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是您使用push()以来的预期行为。此函数每次都会生成唯一的ID。
来自身份验证过程的UID与Push()生成的UID不同。实际上,每次启动应用程序时都一样。因此,当您将数据写入数据库时,请停止使用push()并使用UID:
That's the expected behavior since you're using push(). This function generates a unique ID each time is called.
The UID that comes from the authentication process, it's different than the one that is generated by push(). It's actually the same, each time you launch your app. So when you write data to the database, stop using push() and use the UID: