Creating users and allowing them to log in and out of a web apps is a crucial functionality that I am ready to learn!. In this lesson we’re going to be using passportJs an excellent middleware to handle the user's authentication and sessions.
I am going to be building a very minimal express app that will allow users to sign up, login and log out. For now I am just going to keep everything except the views in one file to make for easier demonstration, but in a real world project, it is best practice to split our concerns and functionality into separate modules.
This project is part of a series of lessons to be completed by developers in The_Odin_Project.
- Express.js.
- PassportJS
- Npm.
- ES6.
- bcrypt.js
- Understand the use order for the required middleware.
- Describe what Strategies are.
- Use the LocalStrategy to authenticate users.
- Explain the purpose of cookies in authentication.
- Refreshed on prior learning material (routes, templates, middleware)
- Use PassportJS to setup user authentication with Express.
- Describe what bcrypt is and its use.
- Explain the importance of password hashing.
- Describe bcrypt’s compare function.
- Access environment variables using the process object in node
- Use dotenv to store and make environment variables available to the application globally.
- Describe how environment variables are handled in version control.
- Work with nconf’s hierarchical configuration
To get a local copy up and running follow these simple example steps.
- Git.
- Code editor.
- browser.
-
Open the terminal.
-
Enter
git clone https://github.com/othman-19/authentication-basics-nodejs
. -
Navigate to the cloned repository.
-
In the terminal cd into authentication-basics-nodejs.
-
Run
npm install
in your terminal. -
Run your local server with
node app.js
. -
Open http://localhost:3000 to view it in the browser.
-
Try subscribe, login and logout.
Othmane Namani.
Email: othmanenaamani@gmail.com.
Portfolio.
LinkedIn.
twitter.
DEV Community.
Angel List.
Contributions, issues and feature requests are welcome!
Feel free to check the issues page.
Give a ⭐️ if you like this project!