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

406
Vistas
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 Respuestas
Responde la pregunta

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 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