【发布时间】:2017-07-18 16:20:12
【问题描述】:
我正在使用 React-Native 和 Firebase 构建一个应用程序。
在另一个应用程序中运行的代码(从 firebase 中提取)这次无法运行。因此,我将其修改为更简单 - 一次数据调用,我收到以下错误:
Possible Unhandled Promise Rejection (id: 0):
Error: permission_denied at /userList: Client doesn't have permission to access the desired data.
即使我将规则设为“真实”(对任何人开放),我仍然会遇到同样的错误。在同一个应用程序的其他地方,我还有其他可用的读/写功能。
这是我当前的规则和数据库结构:
{
"rules": {
"users": {
"$uid": {
".read": "$uid === auth.uid",
".write": "$uid === auth.uid"
}
},
"public": {
"$uid": {
".read": "auth != null",
".write": "auth != null"
}
},
"feedback": {
"$uid": {
".read": "auth != null",
".write": "auth != null"
}
},
"userList": {
"$uid": {
".read": "auth != null",
".write": "auth != null"
}
}
}
}
这是我发出调用的动作创建者:
import firebase from 'firebase';
export const NAMES_FETCH = 'names_fetch'
export const namesFetch = () => {
return (dispatch) => {
firebase.database().ref(`/userList`).once('value').then(function(snapshot) {
var names = snapshot.val();
console.log('FIREBASE PRINT', names)
});
};
};
我已经尝试了所有方法,但我束手无策。谢谢!
【问题讨论】:
-
忘了提到如果我将 ref 更改为 'users' 而不是 'userList' 则相同的代码可以工作
标签: javascript firebase firebase-realtime-database firebase-authentication firebase-security