在Firestore docs中,一种推荐的编写安全规则的方法是
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId} {
allow read, update, delete: if request.auth.uid == userId;
allow create: if request.auth.uid != null;
}
}
}然而,当我创建一个用户时,userID不同于auth.uid (两者都是随机字符串,但都是随机的)。
如何在创建新用户时自动匹配它们?
发布于 2019-03-25 12:30:04
您所显示的规则建议文档的ID应与Firebase身份验证获得的用户的UID匹配。这是标准的做法。如果您的代码不能同时编写文档,那么规则就不会像您期望的那样工作。因此,您可以get the UID of the user并使用它作为文档的ID。
https://stackoverflow.com/questions/55330996
复制相似问题