所以我有 firebase authentication 设置但是当我使用 createUserWithEmailAndPassword()
它确实创建了用户但是用户名/显示名呢?还是头像?
是否可以更改 firebase 中的用户名或头像?
回答1
是的,您可以在 firebase 中更改用户名、头像等。
Firebase 在文档 https://firebase.google.com/docs/auth/web/manage-users#update_a_users_profile 中有一个示例
因此,如果您想更改用户名或个人资料图片,则必须使用 updateProfile 方法
import { getAuth, updateProfile } from "firebase/auth";
const auth = getAuth();
updateProfile(auth.currentUser, {
//Replace "Jane Q. User" to the username you desire
//And Replace the PhotoURL with the desired Image
displayName: "Jane Q. User", photoURL: "https://example.com/jane-q-user/profile.jpg"
}).then(() => {
// Profile updated!
// ...
}).catch((error) => {
// An error occurred
// ...
});