我使用了Firebase auth createUser,用户创建成功并将用户发送到android客户端,我想从用户Record中获取Firebase用户,但应用程序崩溃了
云功能代码:。
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
admin.initializeApp();
exports.createAccount = functions.https.onCall((data, context) => {
const userEmail = data.email;
const userPassword = data.password;
return admin.auth().createUser({
email: userEmail,
password: userPassword
}).then((userRecord) => {
return {
user: userRecord
}
}).catch((error) => {
// console.log("Error creating new user:", error);
if (error.code === "auth/email-already-exists") {
throw new functions.https.HttpsError('already-exists',error.message);
} else if (error.code === 'auth/invalid-email') {
throw new functions.https.HttpsError('invalid-argument',error.message);
} else {
throw new functions.https.HttpsError('unknown', error.message);
}
});
})