I am trying to register user with createUserWithEmailAndPassword function, which logically receives only email and password. But I want also to write fullname field of user. Can you tell me what is the way of doing this? Thanks
Asked
Active
Viewed 281 times
0
-
Then take the name as an input from the registeration. – Rafee Mar 02 '21 at 06:41
-
@Rafee firebase doesn't allow to create custom fields when registration but there must be some trick to do it – KoboldMines Mar 02 '21 at 06:43
-
Trying console your user after registeration. you can see details `user.displayName` – Rafee Mar 02 '21 at 06:45
-
In place of passing username and password fields, pass full name and password as arguments. – Badri Paudel Mar 02 '21 at 06:46
-
@BadriPaudel I mean where? I use createUserWithEmailAndPassword. It only accepts email and password. But where to pass fullName. Thats what I am here for – KoboldMines Mar 02 '21 at 06:47
-
You cannot add additional fields with reateUserWithEmailAndPassword. to do it, you have to create a User table in your database, listen when authentication changes and update user with provided username. See this post: https://stackoverflow.com/questions/43509021/how-to-add-username-with-email-and-password-in-firebase – Vo Quoc Thang Mar 02 '21 at 07:29
1 Answers
1
But I want also to write fullname field of user.
I make the assumption that you want to update the displayName
property of the user
Object.
Do as follows, by using the updateProfile()
method:
firebase.auth().createUserWithEmailAndPassword(email, password)
.then((userCredential) => {
// Signed in
var user = userCredential.user;
return user.updateProfile({displayName: "Your name"});
})
.then(() => {
console.log("Profile updated successfully!");
})
.catch((error) => {
var errorCode = error.code;
var errorMessage = error.message;
// ..
});

Renaud Tarnec
- 79,263
- 10
- 95
- 121