电话验证身份验证不允许访问 Firestore 中的数据

问题描述 投票:0回答:1

我面临从 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 时缺少什么。 我正在处理高度敏感的数据,因此无法在测试模式下运行数据库

感谢任何帮助,提前致谢。

更新: 我在模拟器中测试了这个,规则在那里正常工作 enter image description here

javascript firebase authentication google-cloud-firestore firebase-authentication
1个回答
0
投票

我发现了问题。 Firestore 上强制执行了应用程序检查。禁用后,问题解决。我不确定为什么 App Check 会阻止读取和写入

但是,我验证了我的安全规则运行正常,只允许经过身份验证的用户读取和写入。

© www.soinside.com 2019 - 2024. All rights reserved.