【问题标题】:Firebase functions.auth.UserRecord is not a functionFirebase functions.auth.UserRecord 不是函数
【发布时间】:2019-06-07 12:21:30
【问题描述】:

我正在尝试触发 Firebase 函数,emailVerifiedauth.UserRecord 中为真,但下面的代码在部署到 Firebase 时抛出 TypeError: functions.auth.UserRecord is not a function 错误.

可以收听emailVerified吗?

我可以触发用户的onCreate,但该功能是用于在 Stripe 中创建客户,我希望这仅在电子邮件验证时发生。

监听的功能是

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;
  }
});

【问题讨论】:

    标签: javascript firebase firebase-authentication google-cloud-functions


    【解决方案1】:

    现有的 Cloud Functions 的唯一 Firebase 身份验证触发器是 functions.auth.user().onCreate((user)functions.auth.user().onDelete((user)。电子邮件验证没有 Cloud Functions 触发器。

    另见:

    【讨论】:

    猜你喜欢
    • 2020-07-01
    • 2020-03-14
    • 2020-10-12
    • 2017-08-04
    • 1970-01-01
    • 1970-01-01
    • 2020-11-05
    • 2017-10-07
    相关资源
    最近更新 更多