This project demonstrates a user authentication system built using Node.js, Express.js, MongoDB, and session management for user login, registration, and access control. User credentials are securely stored in the MongoDB database with MD5 encryption.
- Login Page: Allows existing users to log in.
- Invalid Credentials Handling: Displays an error message for invalid login attempts.
- Registration Page: Enables new users to create an account with credentials securely stored in MongoDB using MD5 encryption.
- Unauthorized Access Handling: Shows an error when users attempt to access restricted pages without logging in.
Login Page | Invalid Credentials |
---|---|
Registration Page | Unauthorized Access Error |
---|---|
Home Page | MongoDB Database |
---|---|
- Clone the repository.
- Install dependencies using
npm install
. - Set up your MongoDB connection by configuring the database in
config.js
. - Run the application using
npm start
. - Access the application in your browser at
http://localhost:3100
.
- Visit the login page (
http://localhost:3100/login
) to log in with existing credentials. - To create a new user account, navigate to the registration page (
http://localhost:3100/register
). - Access restricted pages and observe the handling of unauthorized access.
- Node.js
- Express.js
- MongoDB
- Sessions
Contributions are welcome! Feel free to open issues and pull requests.