Javascript 如何检测在云功能中创建的新firebase用户?

Javascript 如何检测在云功能中创建的新firebase用户?,javascript,firebase,firebase-realtime-database,google-cloud-functions,Javascript,Firebase,Firebase Realtime Database,Google Cloud Functions,我需要在firebase auth中创建新用户时进行检测,然后对其作出反应。我需要在javascript中为一个云函数执行此操作。它必须用于实时数据库 以下是您在firestore中的操作方式: functions.auth.user().onCreate(async (user) => { // const customer = await stripe.customers.create({ email: user.email }); // const intent = aw

我需要在firebase auth中创建新用户时进行检测,然后对其作出反应。我需要在javascript中为一个云函数执行此操作。它必须用于实时数据库

以下是您在firestore中的操作方式:

functions.auth.user().onCreate(async (user) => {
//    const customer = await stripe.customers.create({ email: user.email });
//    const intent = await stripe.setupIntents.create({
//      customer: customer.id,
//    });
//    await admin.firestore().collection('stripe_customers').doc(user.uid).set({
//      customer_id: customer.id,
//      setup_secret: intent.client_secret,
//    });
//    return;
//  });
以下是我到目前为止的情况:

 exports.createStripeCustomer = functions.database
 .ref('/PeopleWhoFollowMe/{uid}/{followerUID}')
 .onCreate((snapshot, context) => {
   const uid = context.params.uid
   const followerUID = context.params.followerUID
   //addNewFollowToNotif(uid, followerUID)
   return updateUsersTimeLines(uid, followerUID) 
 })

Firebase具有其他UserInfo isNewUser

AdditionalUserInfo:{isNewUser:boolean;profile:Object | null;providerId:string;username?:string | null}

firebase.auth().signInWithPopup(provider).then((result) => {
  console.log(result.additionalUserInfo.isNewUser);
});



很难确切地知道您正在做什么,但这将检查用户创建时,它将在数据库中找到该路径并添加该数据。您需要的是包含UserData的
user
对象,我这样实现()并得到以下错误:每个then()应该返回一个值或throweslintpromise/always return,所以我通过quick fix://eslint disable next line promise/always return解决它。这样行吗?还是改变了功能?这是编辑错误,eslint。检查它是否工作。它应该很好,它不会部署,就像我拥有的那样。错误:分析函数触发器时出错。是的,因为您做错了,让我检查是否可以使其工作,firestore是否正常。我实现了您的代码,运行deploy但获取:错误:错误分析触发器:找不到模块。/internalFunctions
exports.onCreateAuthUser = functions.auth.user().onCreate(user => {
   console.log(user);
  //do other stuff
});