gpt4 book ai didi

firebase - Firebase v3 updateProfile方法

转载 作者:行者123 更新时间:2023-12-04 13:22:22 24 4
gpt4 key购买 nike

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com