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

121
Visualizações
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
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