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

252
Visualizações
Nodejs user profiles and sessions

The goal is to build a user profile system for my web application. A user would be able to login, maintain a session and see his profile. After reading various tutorials online about how to do this, I feel a bit lost. Everyone uses different libraries and as someone new to web development, it's not clear what each library does. I've seen the following libraries used, can someone explain the flow of user-profile interactions and where each library comes in?

passport
passport-local
bcrypt-nodejs
connect-flash
express-session

jsonwebtoken
express-jwt

morgan
cookie-parser
about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

One way to start your learning can be at: https://www.youtube.com/watch?v=Z1ktxiqyiLA There I learned how to use the most of plugins from your question.

Ok so about the plugins:

  • passport passport is a node.js plugin which is used usually with express that works as a middleware responsible for the authorization and authentication

  • passport-local - is a plugin for passport, more technically a strategy of authentication which usually is used with a database or configuration file.

  • bcrypt-nodejs is used usually for crypting the passwords in the database (but it is much more powerfull than that), is not cool to save password in plain text.

  • connect-flash - is used for flash messages that appears on a page "The user was successfully added", "Invalid user credentials", or any other success or error messages that you want to display on a page.

  • express-session - is an express middleware which is responsible to store the user session.

  • jsonwebtoken - jwt is used to create a token which you will use to identify if an user was authenticated or not.

  • express-jwt - an express middleware for jsonwebtoken

  • cookie-parser - an express middleware to parse cookies

  • morgan - just a log-ing service.

Ok so you should understand a bit of theory here:

  • passport with passport-local strategy is a statefull authentication mechanism which is supposed to save if the user is authenicated or not in a session, if you restart the node.js server if you did not persist your sessions in a third party service as a database/file etc... you will lose the sessions.

  • jsonwebtoken is a stateless authentication mechanism, you do not need to save anything on your server only the "secret key". Stateless architecture has some cool pros as it promotes horizontal scalability you can have endless nodes which will know how to parse the sended token and understand if the user is logged in or not. Lately I go with jwt as authentication.

about 4 years ago · Santiago Trujillo Relatório
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