【问题标题】:firebase realtime database rules, give access to user to access another user datafirebase 实时数据库规则,允许用户访问另一个用户数据
【发布时间】:2018-05-07 09:53:21
【问题描述】:

我想将用户个人资料的访问权限授予用户自己设置的特定用户 在这条规则中,我想让 $userid 能够访问 $user_id 数据

(如果 $user_id 存在于 allow_list/$userid/ 中),我尝试了 root.child('allow_list/'+auth.uid+'/$user_id').exists())" 但它不起作用 这是我现在的规则,不起作用

“users_private”:{

     "$user_id":                 {
               ".write": "auth != null && $user_id === auth.uid",
                ".read":"(auth != null) && ($user_id === auth.uid 
            || root.child('allow_list/'+auth.uid+'/$user_id').exists())"
                               } 

              },


  "allow_list":{

                 "$userid": {

//忽略他们正在工作的这些规则

  ".read":"auth != null && $userid === auth.uid"  ,

                                 "$user_id": {
         ".write": "($userid == auth.uid || $user_id == auth.uid )&&
                              ( $userid!=$user_id)",


                                               }
                                     }
                  },

【问题讨论】:

    标签: firebase-realtime-database firebase-security


    【解决方案1】:

    我找到了方法,希望这对某人有所帮助。

    我加了.child,所以规则是这样的:

    || root.child('allow_list/'+auth.uid+'/').child($user_id).exists())
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-09
      • 2018-10-22
      • 1970-01-01
      • 2019-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-22
      相关资源
      最近更新 更多