【发布时间】:2021-10-19 05:48:24
【问题描述】:
我在我的项目中进行了一个月的编码工作。在我放暑假之前,一切都很顺利。我有工作身份验证(电子邮件/密码),并且能够向/从 Firestore 模拟器写入和读取数据。
我从暑假回来后身份验证仍然有效,但对 Firestore 模拟器的读/写操作停止了。给我错误“缺少权限或权限不足”。
自 7 月以来几乎没有任何变化。网站正在生产中,突然停止开发。
我错过了今年夏天 Firestore 的重大更新吗?还有其他人遇到类似问题吗?
我已尝试更新 firebase 和 firebase-tools、项目构建,只有身份验证有效,但 firebase 不断抛出错误。我的安全规则适用于生产环境。
编辑:我尝试从 firebase 获取的代码。与以前工作的代码相同。
props.firebase
.assessments()
.orderBy('name')
.get()
编辑:安全规则
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Everything else only available to logged in users
match /{document=**} {
allow read, write: if true; // Changed to troubleshoot in development
// request.auth != null;
}
// Only allow users to read, update their own user profile
match /users/{userId} {
allow update, write: if request.auth != null
&& request.auth.uid == userId;
allow read: if request.auth != null;
}
// Restrict team visibility to team members
match /teams/{team} {
allow read, write: if request.auth != null
&& exists(/databases/$(database)/documents/memberships/$(request.auth.uid+'_'+team) )
}
match /tasks/{task} {
allow read, write: if request.auth != null
&& get(/databases/$(database)/documents/users/$(request.auth.uid)).data.teams[request.resource.data.team];
}
}
}
【问题讨论】:
-
请编辑您的问题并添加您正在使用的安全规则。
-
好点。我在下面添加了安全规则。
-
我添加了一个简单的示例,我有一个 firebase 对象,我一直在使用它来获取数据并将数据写入 firestore。
标签: firebase google-cloud-firestore