[英]How to Allow only one user per referral code in flutter firestore?
I am builing a flutter firestore app in which I want to be able to send a referral code to a new user and per referral code only one new user should be able to join.我正在构建一个 flutter firestore 应用程序,我希望能够在其中向新用户发送推荐代码,并且每个推荐代码只有一个新用户应该能够加入。
Please tell me how can I implement this in in flutter app.请告诉我如何在 flutter 应用程序中实现这一点。
Thanks.谢谢。
You can generate them with function you like, store them as documents in separate collection (document name is referral code - this will give you uniqueness of codes) then when user uses it you write his auth id in special field.您可以使用您喜欢的 function 生成它们,将它们作为文档存储在单独的集合中(文档名称是参考代码 - 这将为您提供代码的唯一性)然后当用户使用它时,您在特殊字段中写入他的身份验证 ID。 Then in security rules you make rules that field may be updated only if there is no id there already.
然后在安全规则中,您制定规则,只有在没有 id 的情况下才可以更新该字段。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.