firebase - 如何为不同的用户制作firebase的数据库
问题描述
伙计们,我真的需要你的帮助。一个多月以来,我一直在使用 Vue js、Firebase 和 Firestore 开发一个看起来有点像待办事项列表应用程序的项目。到目前为止,我已经能够设计一个登录和注册页面来对用户进行身份验证,然后他们才能使用这个应用程序。我使用 Firebase 的存储来存储用户在商店中创建的每个待办事项。但是,当我尝试通过使用不同用户(即用户 A、用户 B 和用户 C)登录来测试应用程序时。如果用户 A 将待办事项添加到列表中,则待办事项列表将使用当前待办事项用户 A 进行更新刚刚添加,但这里的问题是用户 B 和用户 C 能够看到用户 A 添加的任何内容,这发生在所有用户身上。拜托,我想让任何登录用户创建的任何待办事项都只能由待办事项的创建者看到,而其他任何第三方都不能看到。
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write;
}
}
}
但是在我更改其他规则以允许经过身份验证的用户读取和写入他们的数据之后
service cloud.firestore {
match /databases/{database}/documents {
// Make sure the uid of the requesting user matches name of the user
// document. The wildcard expression {userId} makes the userId variable
// available in rules.
match /users/{userId} {
allow read, update, delete: if request.auth.uid == userId;
allow create: if request.auth.uid != null;
}
}
}
创建的数据未显示,并且我的控制台上出现读取 FirebaseError:缺少或权限不足的错误。
解决方案
推荐阅读
- security - 项目缺少活动日志
- reactjs - pass ref to a class component with React.cloneElement and render prop
- c# - Coinbase API - 交易
- node.js - 猫鼬搜索子类别
- uefi - 识别 EFI 中的修饰键
- java - 尝试从输入字段中读取日期值时获取未定义的值
- batch-file - 简单的 if 语句批处理
- java - 如何配置 Spring WS 以生成 SOAP 1.2
- visual-studio - 带有 Visual Studio 2017 的 3DS Max 插件向导
- algorithm - Dynamic Programming Solution for a Variant of Coin Exchange