【发布时间】:2018-06-04 02:41:17
【问题描述】:
我有一个基于新身份验证触发的 firebase 云功能,该身份验证将用户信息记录在 firebase 实时数据库中。由于某种原因,云功能未触发,用户未在数据库中注册。 这是我尝试部署的云功能的代码
Index.js
const functions = require('firebase-functions')
const admin = require('firebase-admin')
admin.initializeApp(functions.config().firebase);
const ref = admin.database().ref()
exports.creatUserAccount = functions.auth.user().onCreate(event => {
const uid = event.data.uid
const displayName = event.data.displayName
const email = event.data.email
const photoURL = event.data.photoURL || 'https://yt3.ggpht.com/-Sz69_iENQd4/AAAAAAAAAAI/AAAAAAAAAAA/zLg-bS6DJFo/s900-c-k-no-mo-rj-c0xffffff/photo.jpg'
const phoneNumber = event.data.phoneNumber || ''
const batchList = ['']
const newUserRef = ref.child(`/users/students/${uid}`)
return newUserRef.set({
displayName: displayName,
email: email,
photoURL: photoURL,
uid: uid,
isDeleted: false,
phoneNumber: phoneNumber,
batchList: batchList,
})
})
exports.deleteUserAccount = functions.auth.user().onDelete(event => {
const uid = event.data.uid
const userRef = ref.child(`users/students/${uid}`)
return userRef.update({ isDeleted: true })
})
firebase 日志为空,无法帮助我解决问题
【问题讨论】:
标签: firebase firebase-realtime-database firebase-authentication google-cloud-functions