April Gray
April Gray

Reputation: 41

Firestore Permission denied in production Electron app but requests go through in development

I have added multiple rules to my Firestore database. When I test the app in development mode, everything works as it should but for some reason when I build and run the app for production all my requests are denied with "Missing or insufficient permissions."

I cannot allow anyone to read, and the documents. The rules are vital and I am not sure that they are the problem anyway. I have used the Firestore simulator to test calls, as well as the emulator.

I am building with the command:

electron-builder build --win --x64

The rules

match /databases/{database}/documents {
 function owns(id) {
   return request.auth.uid == id;
 }
 match /{userId}/{document=**} {
   allow read, write: if owns(userId);
 }
}
load(collectionName) {
  const uid = firebase.auth().currentUser;
  let collection = uid && 
   firebase.firestore().collection(uid).doc("data").collection(collectionName);
  }

  return collection.get();
}

Basically the top level of the database is the user ids, and a user can access collection within their top-level collection.

Upvotes: 0

Views: 450

Answers (1)

April Gray
April Gray

Reputation: 41

This was due to an issue in firebase-js-sdk

The corresponding issue is here: https://github.com/firebase/firebase-js-sdk/issues/1491

Upvotes: 1

Related Questions