firebase - Firebase v3 updateProfile方法

标签 firebase firebase-authentication

Firebase v3 Auth提供了一种updateProfile方法,该方法将displayNamephotoURL传递给Firebase。

我的理解是,这些属性是在用户登录后从第三方oAuth提供者Google,Facebook,Twitter或GitHub检索的。如果使用基于密码的身份验证,则在管理控制台中将无法使用或查看这些密码。

我可以为密码身份验证帐户存储此信息吗?如果可以,我可以通过管理控制台查看/管理此信息吗?

顺便说一句:我知道这可以存储在users节点/分支下的实时数据库中,但是我在询问是否将此信息存储在Firebase Auth系统中。

enter image description here

// Updates the user attributes:
user.updateProfile({
  displayName: "Jane Q. User",
  photoURL: "https://example.com/jane-q-user/profile.jpg"
}).then(function() {
  // Profile updated successfully!
  // "Jane Q. User"
  var displayName = user.displayName;
  // "https://example.com/jane-q-user/profile.jpg"
  var photoURL = user.photoURL;
}, function(error) {
  // An error happened.
});

// Passing a null value will delete the current attribute's value, but not
// passing a property won't change the current attribute's value:
// Let's say we're using the same user than before, after the update.
user.updateProfile({photoURL: null}).then(function() {
  // Profile updated successfully!
  // "Jane Q. User", hasn't changed.
  var displayName = user.displayName;
  // Now, this is null.
  var photoURL = user.photoURL;
}, function(error) {
  // An error happened.
});

最佳答案

.updateProfile在Firebase Auth系统中存储displayNamephotoURL属性。因此,无需在实时数据库中的users节点下设置/获取这些内容。

您将不会在Firebase v3身份验证控制台中看到这些属性。这样就看不到了。

卷成一个,这里如何注册密码用户:

registerPasswordUser(email,displayName,password,photoURL){
  var user = null;
  //nullify empty arguments
  for (var i = 0; i < arguments.length; i++) {
    arguments[i] = arguments[i] ? arguments[i] : null;
  }

  firebase.auth().createUserWithEmailAndPassword(email, password)
  .then(function () {
    user = firebase.auth().currentUser;
    user.sendEmailVerification();
  })
  .then(function () {
    user.updateProfile({
      displayName: displayName,
      photoURL: photoURL
    });
  })
  .catch(function(error) {
    console.log(error.message);
  });
  console.log('Validation link was sent to ' + email + '.');
}

关于firebase - Firebase v3 updateProfile方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38559457/

相关文章:

firebase - Firebase Functions 写入 Cloud Firestore 数据库时是否会计算写入次数?

android - Firebase Analytics 未显示 iOS 应用的用户参与度

java - Facebook 登录错误 "disabled Oauth client flow"但我已启用它

java - Android - Firebase - 不同类型的用户登录

swift - ViewController segue 和登录

swift - 如何处理登录 View

android - 为什么 Firebase 和 Google Analytics 指标不匹配?

javascript - 如何在 Firebase Web 中创建两个用户组

android - Firebase 未报告与 OkHttp 相关的崩溃

ios - 类型 'AuthDataResult' 的值没有成员 'providerID' Firebase 5.0