【发布时间】:2018-09-01 01:00:25
【问题描述】:
我的 Firestore 云数据库有一条基本规则。我想给用户所在的用户咖啡馆,但我总是收到错误“缺少权限或权限不足。”。我错过了什么?
service cloud.firestore {
match /databases/{db}/documents {
match /cafes{
allow read: if request.auth.uid != null;
match /{cafe}{
allow read: if get(/databases/$(db)/documents/cafes/$(cafe)/participants/$(request.auth.uid)) != null;
}
}
}
}
这是我用来访问文档的代码
export class MyApp {
private rootPage:any;
// rootPage:any = HomePage;
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, afAuth: AngularFireAuth, afs: AngularFirestore) {
platform.ready().then(() => {
statusBar.styleDefault();
splashScreen.hide();
afAuth.auth.onIdTokenChanged(user=>{
if(user){
console.log(user.uid)
afs.collection('cafes').valueChanges().subscribe(console.log)
} else {
console.log('logged out')
}
})
});
}
}
【问题讨论】:
-
您还应该包含您用来尝试阅读的代码(并给出错误)。
标签: firebase firebase-realtime-database firebase-authentication google-cloud-firestore