Firebase functions.auth.UserRecord is not a function

Viewed 678

I am trying to trigger a Firebase Function upon emailVerified is true in auth.UserRecord but the below code is throwing a TypeError: functions.auth.UserRecord is not a function error when deploying to Firebase.

Is it possible to listen for emailVerified?

I could trigger onCreate of user but the function is to be for creating customers in Stripe and I would prefer this only happen upon email verification.

The function for listening is

exports = module.exports = functions.auth
.UserRecord((uid, emailVerified) => {
  // isVerified
  if (emailVerified) {
    const cid = admin
      .database()
      .ref()
      .push().key;

    var customerObject = {
      id: cid,
      dateCreated: new Date(),
      dateModified: new Date()
    };

    return admin
      .firestore()
      .doc(`users/${uid}/billing/${cid}`)
      .set(customerObject);
  } else {
    // isNotVerified
    return null;
  }
});
1 Answers
Related