Firestore Security Rules: Allow User To Create Doc Only If New Doc ID is same as User ID

前端 未结 3 611
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-01 02:02

When users log in for the first time, I need to also call a function that creates a document in my firestore users collection to store their profile data. Using Web SDK.

3条回答
  •  一整个雨季
    2021-01-01 02:56

    A little bit late, but I manage to tweak one of your possible solutions and make it work:

    allow create: if path("/databases/(default)/documents/users/" + request.auth.uid) == request.path;
    

    Just had to replace the database variable with (default). Yes, not fancy...

提交回复
热议问题