【发布时间】:2020-10-14 18:54:36
【问题描述】:
刚启动应用后,我没有登录,我尝试通过id读取文档:
static async getUserByUID(uid) {
let ref = firebase.firestore().collection("users");
let user = await ref.doc(uid).get()
return user
}
我得到一个错误:
Missing or insufficient permissions.
* http://127.0.0.1:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:184506:21 in e
- node_modules/@firebase/firestore/dist/index.cjs.js:1:23672 in t.prototype.Vt
- node_modules/@firebase/firestore/dist/index.cjs.js:1:31796 in t.ee
- node_modules/@firebase/firestore/dist/index.cjs.js:1:148981 in <global>
- node_modules/@firebase/firestore/dist/index.cjs.js:1:48518 in e
- node_modules/promise/setimmediate/core.js:37:14 in tryCallOne
- node_modules/promise/setimmediate/core.js:123:25 in setImmediate$argument_0
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:146:14 in _callTimer
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:194:17 in _callImmediatesPass
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:458:30 in callImmediates
* [native code]:null in callImmediates
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:407:6 in __callImmediates
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:143:6 in __guard$argument_0
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:384:10 in __guard
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:142:17 in __guard$argument_0
* [native code]:null in flushedQueue
* [native code]:null in callFunctionReturnFlushedQueue
我的规则是:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth.uid != null;
}
}
}
如果我打开所有权限一切正常,有什么建议吗?
【问题讨论】:
标签: javascript firebase react-native firebase-authentication firebase-security