A secure Authentication System built using Node.js, Express.js, MongoDB, Mongoose, bcrypt, JWT, Cookies, and EJS.
This project demonstrates a complete authentication flow including user registration, login, password hashing, JWT authentication, cookie-based session handling, and protected routes.
- User Registration (Sign Up)
- User Login
- Secure Password Hashing using bcrypt
- JWT Token Authentication
- Cookie-Based Session Handling
- Protected Dashboard Route
- Logout Functionality
- MongoDB Database Integration
- EJS Templating Engine
- Simple Instagram-inspired UI
- Node.js
- Express.js
- MongoDB
- Mongoose
- bcrypt
- JSON Web Token (JWT)
- Cookie Parser
- HTML
- CSS
- EJS
- Git
- GitHub
authentication-system-nodejs
โ
โโโ models
โ โโโ User.js
โ
โโโ public
โ โโโ style.css
โ
โโโ views
โ โโโ signup.ejs
โ โโโ login.ejs
โ โโโ dashboard.ejs
โ
โโโ app.js
โโโ package.json
โโโ package-lock.json
โโโ .gitignore
User signs up with username & password Password is hashed using bcrypt Stored securely in MongoDB
Credentials are verified Password compared using bcrypt JWT token generated on success
Token stored in browser cookies Used to access protected routes
Only authenticated users can access dashboard Invalid token blocks access
JWT cookie is cleared User redirected to login page
Signup โ Login โ Dashboard โ Logout
git clone https://github.com/LashminiAD/authentication-system-nodejs.git cd authentication-system-nodejs npm install Start MongoDB mongodb://localhost:27017/AuthDB Run Project npm start
or
nodemon app.js Open in Browser http://localhost:3000