gpt4 book ai didi

ios - 如何使云 Firestore 身份验证 Uid 与用户 ID 匹配?

转载 作者:行者123 更新时间:2023-11-29 05:54:10 25 4
gpt4 key购买 nike

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 不同(两者都是随机字符串,但完全随机)。

创建新用户时如何使它们自动匹配?

最佳答案

您显示的规则表明文档的 ID 应与通过 Firebase 身份验证获取的用户的 UID 相匹配。这是标准做法。如果您的代码没有同时编写此文档,那么该规则将无法按您的预期工作。所以,你get the UID of the user并将其用作文档的 ID。

关于ios - 如何使云 Firestore 身份验证 Uid 与用户 ID 匹配?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55330996/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com