【发布时间】:2023-04-03 18:07:01
【问题描述】:
我正在尝试在创建帐户后更新 Firebase 帐户的个人资料,但它不起作用
我已经尝试检查它是否适用于
console.log(AuthUser.user.displayName());
它说 displayName 不存在,所以我认为我做错了什么
这是我的新用户创建代码
auth.doCreateUserWithEmailAndPassword(email, passwordOne)
.then(authUser => {
this.setState(() => ({ ...INITIAL_STATE }));
authUser.user.updateProfile({
displayName: firstName + " "+lastName
})
})
.catch(error => {
this.setState(byPropKey('error', error));
});
【问题讨论】:
-
你在哪里打印了这个
console.log(AuthUser.user.displayName());?您可能会在 updateProfile 完成之前记录显示名称。检查 firebase,用户个人资料可能已经更新。 -
onAuthStateChange 没有捕获 updateProfile 事件
-
我已经检查了 firebase 控制台并且配置文件没有被更新(但 authUser.user.updateProfile 没有抛出任何错误)
-
尝试添加这个。
user.updateProfile({displayName: 'test-name'}).then(function() { var displayName = user.displayName; console.log('profile updated'); }, function(error) { // An error happened. }); -
成功了!发布它,我会接受答案
标签: firebase firebase-authentication