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

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

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