我无法在规则到位的情况下读写数据到Firestore。
我可以访问我的数据并对其进行操作,而无需设置如下所示的规则:
match /{document=**} {
allow read, write: if true;
}
但是我遵循以下规则出现“权限被拒绝”错误。
match /{document=**} {
allow read, write: if request.auth.uid != null;
}
这是我的飞镖代码:
if (uid == null) {
user = await a.currentUser();
uid = user.uid;
}
DocumentReference docRef = firestore.collection('users').document(uid);
CollectionReference locations = docRef.collection('locations');
await locations.document().setData(<String, double>{
'latitude': latitude,
'longitude': longitude,
});
我可以想到此请求失败的两种情况:
[请帮助我调试此问题。
将规则更改为allow read,write: if request.auth !=null;