我面临从 Firestore 获取数据的问题
Error : FirebaseError: Missing or insufficient permissions.
将规则更改为以下后
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}
下面是我尝试调用数据库的函数
async handelSearch(searchTerm: any) {
onAuthStateChanged(this.auth, async (user) => {
if (user) {
// User is signed in, see the user's uid
console.log(user.uid)
const querySnapshot = await getDocs(q);
let temp: any[]=[]
querySnapshot.forEach((doc) => {
// doc.data() is never undefined for query doc snapshots
temp.push(doc.data())
});
this.serachBarService.MemberList.update(() => temp);
// Access and modify user data here
} else {
console.log("No auth")
// User is signed out
}
});
}
我成功地能够通过控制台记录用户 ID,身份验证似乎工作正常,但我不知道访问 firestore 时缺少什么。 我正在处理高度敏感的数据,因此无法在测试模式下运行数据库
感谢任何帮助,提前致谢。
我发现了问题。 Firestore 上强制执行了应用程序检查。禁用后,问题解决。我不确定为什么 App Check 会阻止读取和写入
但是,我验证了我的安全规则运行正常,只允许经过身份验证的用户读取和写入。