--- user: josh

问题描述 投票:0回答:1

我有一个firebase的json是这样的。

--- userid: v5s8fd8f7 (the auth user id from firebase auth) I'd like to ...

-Hhnfdb743HvGdF (the post key)
 |
 --- user: josh
 |
 --- profile: /img/img.jpg
 |
 --- userid: v5s8fd8f7 (the auth user id from firebase auth)

You're using

 "posts": {
    "$uid": {
        ".read": true,
        ".write": "auth != null && 
               auth.uid == data.child('userid').val()"
    }
 }

to look up the UID, which is the data as is exists

/posts/-Hhnfdb743HvGdF/userid/v5s8fd8f7

before

this operation. To get the data as it exists
firebase firebase-realtime-database firebase-security
1个回答
2
投票

:dataSee the Firebase documentation on existing data vs new data.我想只允许这个userid写数据,所以我试了一下。问题是它总是拒绝,即使userid和auth相同,有什么办法吗?newData谢谢

auth.uid == newData.child('userid').val()"

我有一个firebase的json是这样的:帖子。-Hhnfdb743HvGdF (post key) imgimg.jpg

© www.soinside.com 2019 - 2024. All rights reserved.