如何将uid
的{{1}}生成的auth
作为文档的createUserWithEmailAndPassword(email, pass)
?
我将此代码作为注册函数:
uid
上面的代码执行了预期的操作,输出就在这里
因此数据已成功保存,但我希望此$scope.signup = function (user) {
auth.createUserWithEmailAndPassword(user.email, user.password)
.then(ok => {
// remove pass before saving
delete user.password;
// assigning the uid
user.uid = ok.uid;
// saving to userRef = ...ref().child('/accounts')
userRef.push(user)
.then(snap => console.log(snap))
.catch(err => console.log(err));
})
.catch(e => console.log(e.message));
}
的值为-KOQOXUGH9Ahh9fukVkg
的值uid
。
似乎pFNhADogjkZFz7E4osXPY48wJdS2
会自动添加-KOQOXUGH9Ahh9fukVkg
。我该如何控制?
这是我的firebase
rules
答案 0 :(得分:1)
这应该有效:
firebase.database().ref("accounts/" + ok.uid).set(user);