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

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

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