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
Connecting passport.js data with an existing entry in DB

I have a db row that has

{ uniqueId: 'dfklajh123' }

representing a user.

now, I want that user to be able to log in with the help of passport.js, and merge this uniqueId with the data returned from the session. For example:

User 1 is browsing inside my app, and decides to connect their account. He already has a uniqueId. When he gets callbacked using passport.js, the deserializeUser function is called, and at that moment I want to do some work like this (pseudo)

db.update(User).where(uniqueId: 'dfklajh123').insert(passportId: 'idFromPassport');

However, once the deserializeUser is called, I have no access to the uniqueId. How do I access this uniqueId from deserializeUser if I do not have access to the request?

In the examples, they write

passport.deserializeUser(function(id, done) { User.findById(id, function (err, user) { done(err, user); }); });

and this is where I want to access the uniqueId which I will send from the client, to match by, and update the user accordingly.

Any help is appreciated.

about 4 years ago · Juan Pablo Isaza
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!