Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

120
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda