我可以在Firebase控制檯中添加用戶 - > Auth,但除了爲他們設置電子郵件和密碼之外,我無能爲力。Firebase - 沒有用戶的顯示名稱
我可以以某種方式爲它們設置displayName嗎?
我可以在Firebase控制檯中添加用戶 - > Auth,但除了爲他們設置電子郵件和密碼之外,我無能爲力。Firebase - 沒有用戶的顯示名稱
我可以以某種方式爲它們設置displayName嗎?
我想,如果你只是想更新的用戶配置文件:
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
// User is signed in.
user.updateProfile({
displayName: "Random Name"
}).then(function() {
// Update successful.
}, function(error) {
// An error happened.
});
} else {
// No user is signed in.
}
});
我對你的問題的解決方案。所以這裏是:
當你創建一個用戶時,你只用電子郵件和密碼創建它,但你可以和promise中的displayName,然後在.then()方法中調用updateProfile方法,右下是代碼:
onSubmit(formData) {
if(formData.valid) {
console.log(formData.value);
this.af.auth.createUserWithEmailAndPassword(
formData.value.email,
formData.value.password
).then(
(success) => {
console.log(success);
success.updateProfile({
displayName: "Example User",
photoURL: "https://example.com/jane-q-user/profile.jpg"
}).catch(
(err) => {
this.error = err;
});
this.router.navigate(['/login'])
}).catch(
(err) => {
this.error = err;
})
}
}
注意,在我的例子顯示名設置爲「示例用戶」,在現實的應用程序,你只需要添加的參數作爲我的情況下,它應該是 - >顯示名:FORMDATA。 value.name
謝謝
是的,我知道什麼字段authData但我也知道authData有一個名爲「displayName」的字段,該字段對於該類型的身份驗證爲空。例如,當我使用Google身份驗證時,我的回覆displayName是我的Google姓名。所以我的問題是,是否可以爲我在Firebase控制檯中手動創建的用戶設置這些屬性。謝謝。 – elzoy
沒有辦法在控制檯中設置顯示名稱(儘管功能要求很好)。在此之前,調用API是最好的選擇。 –
我發現這個網頁的搜索結果是「firebase console edit user profile」,因爲我也想通過控制檯設置一個用戶的'displayName',並且驚訝地發現我不能。絕對是一個應該添加的功能。 – odigity