Skip to content

Instantly share code, notes, and snippets.

@jperasmus
Last active January 25, 2019 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jperasmus/17d8e85188542458f201b444ebe0bb55 to your computer and use it in GitHub Desktop.
Save jperasmus/17d8e85188542458f201b444ebe0bb55 to your computer and use it in GitHub Desktop.
const functions = require('firebase-functions');
const admin = require('firebase-admin');
exports.addCustomClaim = functions.database.ref('/flamelink/environments/production/content/userAccount/en-US/{entryId}')
.onCreate((snapshot, context) => {
const entry = snapshot.val();
const entryId = context.params.entryId;
const uid = entry.uid;
// user creating the new entry
// const uid = context.auth.uid;
return admin.auth().setCustomUserClaims(uid, {userAccount: entryId});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment