我一定在这里遗漏了一些非常基本的东西......但是每当我调用我的 Cloud Firestore 数据库并尝试制定任何类型的安全规则时,它们总是失败。
做类似的事情
match /users/{userId} {
allow create, read, update: if true;
}Run Code Online (Sandbox Code Playgroud)
有效,但它显然违背了这一点。但是,如果我进行任何类型的额外审查,例如所有文档中的首选示例,例如
match /users/{userId} {
allow create, read, update: if request.auth.uid != null;
}Run Code Online (Sandbox Code Playgroud)
它每次都失败。我是否在如何将客户端代码连接在一起时遗漏了一些明显的东西?
这是我的客户端代码,用于登录用户,然后调用数据库以获取用户。(请注意,在我的数据库中,用户的密钥是通过电子邮件,而不是 uid)
// this is a snippet from the code where I log the user in
firebase.auth().signInWithEmailAndPassword(email, FIREBASE_USER_PASSWORD)
.then(user => {
// the user comes back successfully logged in,
// I grab its uid and add it to a preparedUser object that I've been building,
// then pass this user to …Run Code Online (Sandbox Code Playgroud)firebase firebase-security firebase-authentication google-cloud-firestore