我希望将一个新的文档添加到我的用户集合中,这是由firebase.auth()触发的,但是数据库没有被填充。
这是我的防火墙功能:
exports.newUser = functions.auth.user().onCreate((user) => {
return db
.collection("user")
.doc(user.uid)
.create(JSON.parse(JSON.stringify(user)));
});这是我的注册方法:
export const register = (email, password) => dispatch => new Promise((resolve, reject) => {
firebase.auth().createUserWithEmailAndPassword(email, password)
.then(() => {
resolve()
})
.catch(() => {
console.log(typeof (email, password))
reject()
})
})执行时,新用户将被添加到身份验证中,但不会触发新文档的创建。成功地将函数newUser部署到firebase。
似乎我解析用户数据的方法是不正确的,请建议我遗漏了什么?
功能日志:
下午4:38:51.935 outlined_flag /workspace/node_modules/firebase-functions/lib/common/providers/identity.js:113:70 4:38:52.968 PM newUser at Array.map () 4:38:52.968 PM newUser at Object.record.toJSON newUser 4:38:52.968 PM newUser(/workspace/node_modules/firebase-functions/lib/cloud-functions.js:135:23) 4:38:52.968 PM newUser at / /layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/function_wrappers.js:144:25 /index.js:10:33 4:38:52.968 PM newUser at cloudFunction 4:38:52.968 PM newUser 4:38:52.968PM newUser at processTicksAndRejections (节点:内部/进程/任务队列:96:5) 4:38:52.968 PM newUser TypeError: entry.toJSON不是函数4:38:52.968 PM newUser at Array.map 4:38:52.968 PM newUser at Array.map () 4:38:52.968 PM newUser at Object.record.toJSON (/workspace/node_modules/firebase-functions/lib/common/providers/identity(/workspace/node_modules/firebase-functions/lib/cloud-functions.js:135:23) ( .js:113:49) 4:38:52.968下午newUser at JSON.stringify () more_vert 4:38:52.968 PM newUser at /工作区/index.js:10:33 4:38:52.968 PM newUser at cloudFunction more_vert 4:38:52.968 PM newUser at /layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/96:144:254:38:52.968 PM newUser at processTicksAndRejections (节点:内部/进程/任务队列:96:5) 4:38:52.979 PM outlined_flag newUser函数执行时间为1044 ms。完成状态:错误
发布于 2022-05-12 19:48:55
这里的消防队员
据我所知,这个bug最近被引入到我们的函数SDK中。您可以检查它的状态,在Github问题#1102上。
发布于 2022-05-10 19:10:26
更新:
我尝试了这个函数,它完成了以下工作:
exports.newUser = functions.auth.user().onCreate((user) => {
return db
.collection("user")
.doc(user.uid)
.set({
email: user.email,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString()
})
});https://stackoverflow.com/questions/72185429
复制相似问题