【发布时间】:2018-11-16 02:10:35
【问题描述】:
奇怪的问题,我有一个由 Firebase newUser auth 触发的函数 如果用户使用 Google 或 Facebook 提供程序,则该函数有效,但如果它通过电子邮件/密码注册,则该函数返回未定义的错误。 我在这里缺少什么?
功能代码:
exports.newUser = functions.auth.user().onCreate((user) => {
const docRef = admin.firestore().collection('Users').doc(user.uid)
return docRef.set({
email: user.email,
name: '',
photo: '',
signupDate: admin.firestore.FieldValue.serverTimestamp()
},{merge: true});
});
【问题讨论】:
-
好的,问题似乎出在这个字段 email: user.email 如果用户使用电子邮件注册并且这个 newUser 函数被触发,那么 email 字段是如何未定义的。
-
为什么在 Facebook 和 Google 提供商上定义了此字段,但在电子邮件/密码注册时未定义?
标签: node.js firebase firebase-authentication google-cloud-firestore firebase-admin