Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

119
Vistas
how to add users to firestore using the same id after authentication
const handleSignup = ()=>{
    auth()
    .createUserWithEmailAndPassword(email, password)
    .then((cred) => {
        console.log(cred);
        firestore()
        .collection('users')
        .doc(cred.uid)
        .set({
          display_name:username
        })
        .then(() => {
          console.log('User added!');
        });
    })
    .catch(error => {
        console.log(error.code);
        if (error.code === 'auth/user-not-found') {
          console.error('Invalid Email or password');
        }else
          console.error('Sorry an error occured');
    });
  };

I am using the above code to store user details in firestore and I want the document to be same as the credentials uid which is generated after authnetication.But the id in the doc is completely different that the cred.uid.How to fix this?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The correct syntax is cred.user.uid (instead of cred.uid). For source and more information about this topic check firebase password auth docs.

PS: This was already answered in the comments but I posted the response here as well to be easier to spot (as well as suggest that the question has an answer. Thank you @Frank van Puffelen for the suggestion).

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda