Flutter and Firestore does not have user information in request

旧城冷巷雨未停 提交于 2019-12-05 04:08:13

I meant to post a comment, but my rep is not enough.

Did you find a solution to the error? I would have suggested to make the rule like:

service cloud.firestore {
  match /databases/{database}/documents {
   match /testing123auth/{documents=**} {
    allow read, create: if true;
    }
  }
}

Or, better yet, limit the scope of the user:

service cloud.firestore {
  match /databases/{database}/documents {
    match /testing123auth/{userId} {
      allow read, create: 
        if (request.auth.uid != null &&
            request.auth.uid == userId); // DOCUMENT ID == USERID
      } // END RULES FOR USERID DOC

      // IF YOU PLAN TO PUT SUBCOLLECTIONS INSIDE DOCUMENT:
      match /{documents=**} {
        // ALL DOCUMENTS/COLLECTIONS INSIDE THE DOCUMENT
        allow read, write:
          if (request.auth.uid != null &&
            request.auth.uid == userId);
      } // END DOCUMENTS=**
    } // END USERID DOCUMENT
  }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!