firebasefirebase-authenticationgoogle-cloud-functions

Alternate of Authentication create trigger in 2nd Gen - Cloud Functions


I want to trigger a function when a user is created in Firebase Authentication, and I wrote this

const {onCreate} = require("firebase-functions/v2/auth");

exports.removeInvite = onCreate(async (user) => {
  return await myInviteFunctions.removeInvite(FieldValue, firestoreDB, user);
});

Any alternate code for this in 2nd Gen, as recent updates of firebase-tools are causing the issue on this line and giving the following errors as coding issues enter image description here

and with --debug the error is enter image description here


Solution

  • Thanks to @samthecodingman! Auth v2 functions aren't implemented yet. So I mix it with v1

    const functions = require("firebase-functions"); // v1
    
    exports.removeInvite = functions.auth.user()onCreate(async (user) => {
      return await myInviteFunctions.removeInvite(FieldValue, firestoreDB, user);
    });