0

I'm currently working on a Firebase cloud function and I need to check the user ID is the same as the currently logged in user before proceeding. How would I be able to check the userID in the node before accessing the posts underneath it.

Database example

I've been attempting to use a database trigger as I want to check on write to the database.

So far i've written the function but

exports.sendPushNotification = functions.database.ref('/competitions').onWrite(event => {
const collectionRef = event.data.ref.parent;
snapshot.forEach(function () {
    const countRef = collectionRef.parent.child('posts');

});

});

I just don't know how to access the user id as a variable

Ben Moore
  • 91
  • 1
  • 3
  • 11
  • Can you share some example code for your Cloud Function? Is this for a database trigger or a HTTP trigger? – Grimthorr Nov 17 '17 at 10:56
  • 1
    Possible duplicate of [Getting the user id from a database trigger in Cloud Functions for Firebase?](https://stackoverflow.com/questions/42750060/getting-the-user-id-from-a-database-trigger-in-cloud-functions-for-firebase) – Grimthorr Nov 17 '17 at 11:09

0 Answers0