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

409
Visualizações
firebase v9 I am storing the User UID from firebase auth into firestore, help me retrieve it for sign in comparison

this is my Register function

createUserWithEmailAndPassword(auth, email, password)
      .then((userCredential) => {
        const uid = userCredential.user.uid;
        const data = {
          id: uid,
          email,
          fullName,
        };

        async function storeUserUid() {
          const newUser = doc(collection(db, "users", user.uid));
          await setDoc(newUser, data);
console.log(uid) = aj3x5gAe2jUcngBoTY5cVpOTITu1
console.log(data) = Object {
  "email": "lala@email.com",
  "fullName": "lala",
  "id": "aj3x5gAe2jUcngBoTY5cVpOTITu1",
}

My login function that needs helping. When authenticating it successfully I have console.logged the (uid) which is the first markup in the screenshow below. I am receiving the same uid from the second console.log(userList) under the "id" key. How can I access the object and compare both values so I can let the user then navigate to the "HomeScreen" if there is a match from the signInwithCredentials and the userList id. I need somehow to map through all the docs inside the "users" collection and compare their "id" keys and if there is a match with the signInwithCredentials uid => then, let the user in. MANY THANKS

 const onLoginPress = () => {
    signInWithEmailAndPassword(auth, email, password)
      .then((userCredential) => {
        const uid = userCredential.user.uid;
        console.log(uid);

        async function getUser() {
          const q = query(collection(db, "users"));
          const userSnap = await getDocs(q);
          const userList = userSnap.docs.map((doc) => doc.data());
          console.log(userList);
        }
        getUser();
      })

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If you don't need to get all user docs, but just the one for the current user, that'd be:

async function getUser() {
  const ref = doc(db, "users", FirebaseAuth.instance.currentUser.uid));
  const userDoc = await getDoc(ref);
  return userDoc.data();
}
getUser();
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