Firebase 用户ID写文章的规则
我有一个firebase json,如下所示: 职位:Firebase 用户ID写文章的规则,firebase,firebase-realtime-database,firebase-security,Firebase,Firebase Realtime Database,Firebase Security,我有一个firebase json,如下所示: 职位: -Hhnfdb743HvGdF (the post key) | --- user: josh | --- profile: /img/img.jpg | --- userid: v5s8fd8f7 (the auth user id from firebase auth) 我只允许此用户ID写入其数据,因此我尝试: "posts": { "$uid": { ".read": true,
-Hhnfdb743HvGdF (the post key)
|
--- user: josh
|
--- profile: /img/img.jpg
|
--- userid: v5s8fd8f7 (the auth user id from firebase auth)
我只允许此用户ID写入其数据,因此我尝试:
"posts": {
"$uid": {
".read": true,
".write": "auth != null &&
auth.uid == data.child('userid').val()"
}
}
问题是它总是拒绝,即使userid与auth相同。你知道为什么吗
/posts/-Hhnfdb743HvGdF/userid/v5s8fd8f7
谢谢 您正在使用
数据
查找UID,该UID是此操作之前存在的数据。要获取此操作后存在的数据(如果允许此操作),请使用newData
:
auth.uid == newData.child('userid').val()"
请参阅上的Firebase文档。您正在使用
数据
查找UID,UID是此操作之前存在的数据。要获取此操作后存在的数据(如果允许此操作),请使用newData
:
auth.uid == newData.child('userid').val()"
请参阅上的Firebase文档。谢谢您的回答!我将数据更改为新数据,但仍然拒绝。。。还有什么想法吗/您可以编辑您的问题以包含以下内容吗?请确保尽可能多地硬编码,并记录无法硬编码的值,例如活动用户的UID。感谢您的回答!我将数据更改为新数据,但仍然拒绝。。。还有什么想法吗/您可以编辑您的问题以包含以下内容吗?确保尽可能多地硬编码,并记录无法硬编码的值,例如活动用户的UID。