本文介绍了如何设置Firebase用户的displayName?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
根据Firebase网站上的JS Auth文档,它仅显示如何获取displayName以及如何更新displayName.因此,我尝试对其进行更新.但这有点不合逻辑,因为您如何在不创建内容的情况下进行更新.
According to the JS Auth documentation on the Firebase website, it only shows how to get the displayName and how to update displayName. So I tried to update it. But it is sort of not logical, because how can you update something without creating it.
所以我的问题是,如何在注册过程中设置用户的displayName?
function createUser(email, password) {
firebase.auth().createUserWithEmailAndPassword(email, password).catch(function (error) {
error.message.replace(".", "");
alert(error.message + " (" + error.code + ")");
document.getElementById("password").value = "";
});
if (firebase.auth().currentUser != null) {
firebase.auth().currentUser.updateProfile({
displayName: document.getElementById("name").value
}).then(function () {
console.log("Updated");
}, function (error) {
console.log("Error happened");
});
}
}
我已经尝试过了,但是事实证明它行不通...
I have already tried this and it has been proven not to work...
此致,法鲁克
推荐答案
您必须链接请求:
firebase.auth().createUserWithEmailAndPassword(email, password)
.then(function(result) {
return result.user.updateProfile({
displayName: document.getElementById("name").value
})
}).catch(function(error) {
console.log(error);
});`
这篇关于如何设置Firebase用户的displayName?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!