bradtraversy/node_passport_login
EJSNode.js login, registration and access control using Express and Passport
nodejspassportexpressauthenticationlogin
Key Metrics
Star Growth
Stars
1.8k
Forks
1.3k
Weekly Growth
+-1
Issues
0
5001k1.5k
Jan 2023Aug 2023Apr 2024Nov 2024Jul 2025Mar 2026Oct 2026
README
Node Passport Login
A simple Node.js authentication starter built with Express, Passport, MongoDB, Mongoose, EJS, and Bootstrap.
This project demonstrates:
- Local authentication with Passport
- User registration and login
- Password hashing with bcryptjs
- Protected dashboard route
- Flash messages for validation and auth feedback
- EJS views with a Bootstrap-powered UI
Version
2.0.0
Requirements
- Node.js 22 or newer recommended
- npm
- MongoDB Atlas or a local MongoDB database
Installation
npm install
MongoDB Setup
Open config/keys.js and replace the placeholder MongoDB URI with your own local or Atlas connection string.
Example local URI:
const dbPassword = 'mongodb://127.0.0.1:27017/node_passport_login';
module.exports = {
mongoURI: dbPassword
};
For MongoDB Atlas, use the connection string from your Atlas dashboard and make sure your database username, password, and network access settings are correct.
Do not commit real database credentials to GitHub.
Running the App
npm start
For development with automatic restarts:
npm run dev
Then visit:
http://localhost:5000
Routes
GET /- welcome pageGET /users/register- register pagePOST /users/register- create a userGET /users/login- login pagePOST /users/login- authenticate a userGET /dashboard- protected dashboardGET /users/logout- logout
Scripts
npm start
npm run dev
Dependencies
This project uses current major versions of the main packages, including Express 5, EJS 5, Mongoose 9, Passport 0.7, and Bootstrap 5.