Firebase用户UID与身份验证UID不匹配 [英] Firebase User UID not matching Auth UID

查看:59
本文介绍了Firebase用户UID与身份验证UID不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用Firebase(我正在使用react-redux-firebase,但不确定是否与此问题相关).使用这些标准身份验证规则时出现问题:

I'm new to using Firebase (I'm using react-redux-firebase, but not sure if that's relevant to this question). I'm having an issue using these standard auth rules:

{
   "rules": {
      "users": {
         "$uid": {
            ".read": "$uid === auth.uid",
            ".write": "$uid === auth.uid"
         }
      }
   }
}

这是用户UID,如Firebase身份验证仪表板所示:

This is user UID as shown in the Firebase Authentication dashboard:

但是,如果我打印出与个人资料/帐户相关联的数据,则会得到以下UID:

But if I print out the data associated with the profile/account, I get this UID:

由于这种不匹配,登录用户无法读取或写入Firebase实例.

Because of this mismatch, the logged in user is unable to read or write to the firebase instance.

为什么UID不匹配?我该如何解决这个问题?

Why is there a mismatch in UIDs? How can I solve this issue?

更新:

看起来 1091103… UID是特定于提供程序的,在这种情况下不相关?无法确定这一点.

It looks like the 1091103… UID is provider-specific and not relevant in this case? Can't confirm that for sure.

这可能是实际的身份验证UID(我对此并不陌生,因此仍要弄清楚是什么):

This may be the actual auth UID (I'm new to this, so still trying to figure out what's what):

在这种情况下,此UID与在Firebase控制台中看到的匹配.如果它们匹配,那么权限被拒绝错误的原因是什么?

In this case, this UID matches what is seen in the Firebase console. If they match, then what would be the cause of the permission denied errors?

另一个更新:

这是用户节点.您可以看到UID作为键:

Here's the user node. You can see the UID as the key:

推荐答案

这是您现在可以执行的规则

This is the rule you can do right now

{
  "rules": {
    ".read": "auth != null",
    ".write": "auth != null"
  }
}

如果您要按以下所示进行检查

if you want to check like below

{
   "rules": {
      "users": {
         "$uid": {
            ".read": "$uid === auth.uid",
            ".write": "$uid === auth.uid"
         }
      }
   }
}

您需要在注册时将用户存储到实时数据库.并以他们的 auth.uid 作为密钥.

you need to store the users to realtime database while register. with their auth.uid as key.

这篇关于Firebase用户UID与身份验证UID不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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