I'm having trouble generating a user profile document in Firebase cloud functions using the user.uid as the doc id. Below is the script I am working with, but it keeps failing. I suspect there might be a syntax issue, so any suggestions would be greatly appreciated. Thank you!
import * as functions from 'firebase-functions';
import admin = require('firebase-admin');
// Initialize the app
admin.initializeApp(functions.config().firebase);
// Listen for .onCreate trigger
exports.createProfile = functions.auth.user().onCreate( user => {
return admin.firestore().doc(`users/${user.uid}`).set({
firstName: "",
lastName: "",
email: user.email
})
});
Edit: The user profile document isn't getting created. When attempting to retrieve the user from my Swift app, it gives this error message:
6.19.0 - [Firebase/Firestore][I-FST000001] Listen for query at users/6cWCvz30xVZwp8oVpWxSTUUs2TT2 failed: Missing or insufficient permissions.