This is a simple User Authentication web app using Node.js, Express, MongoDB, and bcrypt. It provides registration and login functionality with password hashing and serves static HTML pages.
.
├── models/
│ └── user.js
├── public/
│ ├── login.html
│ └── register.html
├── .env
├── index.js
├── package.json
└── README.md
-
User Registration (/register)
-
User Login (/login)
-
Password hashing with bcrypt
-
MongoDB connection with mongoose
-
Simple frontend using static HTML
git clone https://github.com/your-username/auth-app.git
cd auth-app
npm install
Create a .env file in the root directory:
MONGO_URI=your_mongodb_connection_string
PORT=3000
Replace your_mongodb_connection_string with your actual MongoDB URI.
node server.js
-
Registration Page: http://localhost:3000/register
-
Login Page: http://localhost:3000/login
Register a new user.
Body Parameters:
{
"username": "yourname",
"email": "your@email.com",
"password": "yourpassword"
}
Login with registered email and password.
Body Parameters:
{
"email": "your@email.com",
"password": "yourpassword"
}
-
Node.js
-
Express.js
-
MongoDB & Mongoose
-
Bcrypt (for password encryption)
-
dotenv
-
HTML/CSS
Passwords are hashed using bcrypt before saving to the database.
For production, consider implementing sessions or JWTs for user authentication.