Here's my code:
firebase.auth().onAuthStateChanged((user) => {
if (user) {
console.log("We are authenticated now!");
firebase.firestore().collection("users")
.doc(firebase.auth().currentUser.uid).set({ name: "new name" });
} else {
loginWithFacebook();
}
});
And, here are my permission rules:
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId} {
allow read, write: if request.auth != null;
}
}
}
It seems like no matter what, request.auth is always null. The error I get:
Firestore (4.8.0) 2017-12-20T04:18:27.321Z [Connection]: WebChannel received error: {"code":403,"message":"Missing or insufficient permissions.","status":"PERMISSION_DENIED"}
I downgraded to Firebase SDK 4.6.2 when I had this problem with latest Firebase JS SDK on Expo.
Also, you have to do this in order for everything to work:
Copy https://gist.githubusercontent.com/mikelehen/444950a35019208f3aaf18d37ab4937c/raw/85ac4cb3108d92163cb8f04fbdddcc88d4081aab/index.js
over your node_modules/@firebase/webchannel-wrapper/dist/index.js
Without this, you'll get nothing from your collections.
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With