Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

401
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!