【问题标题】:Change profile at creating new account with firebase在使用 firebase 创建新帐户时更改个人资料
【发布时间】: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


【解决方案1】:
 authUser.user.updateProfile({
    displayName: firstName + " "+lastName
  })

这行得通,问题是我必须改变

  console.log(AuthUser.user.displayName());

  console.log(AuthUser.user.displayName);

【讨论】:

    猜你喜欢
    • 2015-01-29
    • 2020-12-20
    • 1970-01-01
    • 2010-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多