I setup my cloud functions with firebase-admin like :
const admin = require('firebase-admin');
const fn = require('firebase-functions');
admin.initializeApp(fn.config().firebase);
However I am getting permission denied upon writing on the database. What's weird is it only happens to some collection but not to all of them. Some works, some won't.
My understanding of admin.initializeApp(fn.config().firebase); is that this will allow my cloud functions to have an absolute power over the database regardless of the security rules.
Here's the error:
EDIT
I write the data like this.
exports.foo = fn.database.ref('some-path').onWrite(e => {
// some handling
const ref = e.data.ref;
return ref.child('bar').set('some-data').then( // ).catch( // );
})
