【发布时间】:2020-08-23 07:00:52
【问题描述】:
目前我遇到一个问题,调用 auth#createUser 方法最多需要 10 秒才能继续调用它的 Promise#then 方法。我从火力基地和谷歌云功能记录器获取这些时间戳。我觉得我可能做错了什么,虽然我无法弄清楚我做错了什么。在你说要联系 Firebase 支持之前,我已经联系过了,他们让我来这里。
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
let database = admin.firestore();
exports.createUser = functions.https.onCall((data, response) => {
console.log(data);
console.log(response);
admin.auth().createUser({
email: data.email,
emailVerified: false,
password: data.password,
displayName: data.name,
disabled: false,
}).then(user => {
database.collection('users').doc(data.username).set({
uid: user.uid,
email: data.email,
name: data.name,
username: data.username
}).catch(error => {
throw new functions.https.HttpsError(error)
});
console.log('The entire thing is done successfully!');
return {
response: user
}
}).catch(error => {
throw new functions.https.HttpsError(error);
});
console.log('Found my way to the end of the method');
});
【问题讨论】:
标签: node.js firebase firebase-authentication google-cloud-functions