Buble Dart
Buble Dart

Reputation: 31

Firebase database user info

I’m trying to make a website where a user can login with a username a password and a name

This function is not implemented in firebase authentication option so I tried using its real-time database Here is my code so far:

export function signup(email, password, name) {
  return auth().createUserWithEmailAndPassword(email, password).then((userCredential) => {
      db.ref("users").ref(userCredential.uid).push({
      name: name
    });
  })
}

Saving the data does not work but I think I have a good start.

Upvotes: 0

Views: 134

Answers (1)

Kundan
Kundan

Reputation: 1952

Try passing only one ref() call and set() instead of push():

export function signup(email, password, name) {
  return auth().createUserWithEmailAndPassword(email, password).then((userCredential) => {
    db.ref("users/" + userCredential.user.uid).set({
      name: name
    });
  })
}

Upvotes: 2

Related Questions