This project implements user authentication APIs using Node.js, Express.js, and SQLite. It includes user registration, login, and password update functionality.
✔️ Register users securely with password hashing
✔️ Login with username and password validation
✔️ Update Password with old password verification
✔️ Secure password handling using bcrypt
- Node.js: JavaScript runtime for building the backend.
- Express.js: Framework for handling API routes.
- SQLite: Database for storing user data.
- bcrypt: Library for hashing passwords.
- nodemon: Tool that automatically restarts the server during development when files change.
- app.js - Express server setup & API routes
- userData.db - SQLite database storing user details
- package.json - Dependencies & scripts
The project uses an SQLite database with a single table:
Column | Type |
---|---|
username | TEXT |
name | TEXT |
password | TEXT |
gender | TEXT |
location | TEXT |
Endpoint:
POST /register
Request Body:
{
"username": "adam_richard",
"name": "Adam Richard",
"password": "richard_567",
"gender": "male",
"location": "Detroit"
}
🚨 User already exists → 400 "User already exists"
🔑 Password too short (< 5 characters) → 400 "Password is too short"
✅ Successful registration → 200 "User created successfully"
Endpoint:
POST /login
Request Body:
{
"username": "adam_richard",
"password": "richard_567"
}
🚨 Invalid user → 400 "Invalid user"
🔑 Invalid password → 400 "Invalid password"
✅ Successful login → 200 "Login success!"
Endpoint:
PUT /change-password
Request Body:
json
{
"username": "adam_richard",
"oldPassword": "richard_567",
"newPassword": "richard@123"
}
🚨 Invalid current password → 400 "Invalid current password"
🔑 Password too short (< 5 characters) → 400 "Password is too short"
✅ Successful password update → 200 "Password updated"
Manoj Kumar
GitHub: Manojkumar2806
Feel free to explore, fork, and contribute!
Thank you for taking the time to check out this project! If you have suggestions, improvements, or feedback, don't hesitate to open an issue or submit a pull request. Your input is much appreciated!