Firebase v3 updateProfile方法 [英] Firebase v3 updateProfile Method

查看:85
本文介绍了Firebase v3 updateProfile方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Firebase v3 Auth offers an updateProfile method that passes displayName and photoURL to Firebase.

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

My understanding is that these properties are retrieved from 3rd party oAuth providers Google, Facebook, Twitter, or GitHub upon user login. In case of Password based Auth, they are not available or viewable from the Admin console.

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

Can I store this info for password Auth accounts, and if so can I view/administer this info via the Admin console?

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

BTW: I know this could be stored in the Realtime Database under a users node/branch but I am asking about storing this info in the Firebase Auth system.

// 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.
});

推荐答案

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

.updateProfile stores the displayName and photoURL properties in the Firebase Auth system. Therefore, there is no need to set/get this stuff under a users node in your Realtime Database.

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

You will not see these properties in the Firebase v3 Auth Console. It's not viewable that way.

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

Rolled into one, here how to register a password user:

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 v3 updateProfile方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆