In react native app (through Expo) using firestore permissions - request.auth is always null

前端 未结 7 1905
天命终不由人
天命终不由人 2020-12-31 09:51

Here\'s my code:

firebase.auth().onAuthStateChanged((user) => {
    if (user) {
        console.log(\"We are authenticated now!\");
        firebase.fires         


        
7条回答
  •  我在风中等你
    2020-12-31 10:23

    Please log your UID and confirm it is not null. Then modify the permission rule as -

    // Grants a user access to a document matching their Auth user Id
        service cloud.firestore {
           match /databases/{database}/documents {
             // Collection named "users", document named after the userId
           match /users/{userId} {
             allow read, write: if request.auth.uid == userId;
           }
         }
      }
    

提交回复
热议问题