[英]firebase JS not able to Add firstname lastname after auth
Im working with react-native redux app. 我正在使用react-native redux应用程序。 This is my newly created firebase database.
这是我新创建的firebase数据库。
Everything is working fine, user is able to sign in and Sign-Up as well. 一切正常,用户也可以登录和注册。 But I have this little code after sign-up I'm trying
.set({ firstname, lastname })
firstname, lastname which does not reflect in database. 但是注册后我有这个小代码,我正在尝试
.set({ firstname, lastname })
firstname,lastname不能反映在数据库中。 (github repo: https://github.com/steelx/react-native-redux-app ) (github回购: https : //github.com/steelx/react-native-redux-app )
export const signUpUser = ({ firstname = "", lastname = "", email, password }) => (dispatch) => {
dispatch({ type: SIGN_UP_REQUEST });
firebase.auth().createUserWithEmailAndPassword(email, password)
.then((user) => {
// const currentUser = firebase.auth().currentUser;
// currentUser.updateProfile({
// displayName: `${firstname} ${lastname}`,
// THIS WORKS
// })
firebase.database().ref('users/' + user.uid)
// THIS DOES NOT WORK
.set({ "firstname": 'AJINKYA', "lastname": 'AJINKYA' })
.then(() => {
dispatch({ type: SIGN_UP_SUCCESS, payload: user });
Actions.home();
});
})
.catch((error) => { dispatch({ type: SIGN_UP_FAILURE, payload: authFailMessage(error.code) }); });
};
Firebase rules Firebase规则
{
"rules": {
"users": {
"$uid": {
".read": "auth != null",
".write": "auth != null && auth.uid == $uid"
}
}
}
}
Sorry my bad I was passing uid
as undefined
at ref. 抱歉,我在ref处传递的
undefined
为uid
。 and originally before posting this question the RULES were set to Locked. 并且最初在发布此问题之前,“规则”已设置为“锁定”。
and my rules were also wrong. 我的规则也是错误的 Later I updated rules to => as a quick fix I added these rules.
后来我将规则更新为=>作为快速解决方案,我添加了这些规则。 Everything works fine now.
现在一切正常。
{
"rules": {
".read": "auth != null",
".write": "auth != null"
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.