This is a simple Express.js application for user authentication with session management. It allows users to register, login, and logout.
- User Registration: Users can register with their name, email, and password.
- User Login: Registered users can login using their email and password.
- Session Management: User sessions are managed using the
express-session
middleware. - Password Hashing: User passwords are hashed using bcrypt before being stored in the database.
- Middleware: Includes custom middleware for IP logging and requiring login for accessing certain routes.
Before running this application, make sure you have the following installed:
- Node.js
- MongoDB (running locally or accessible via URI)
-
Clone the repository:
git clone <repository_url>
-
Install dependencies:
npm install
-
Configure MongoDB:
Update the MongoDB connection URI in the
DBConnector
function call inconnections.js
to connect to your MongoDB database.
-
Start the server:
npm start
-
Access the application:
Open your web browser and navigate to
http://localhost:3000
. -
Use the application:
- Register: Click on the "Register" link to create a new account.
- Login: After registration, login with your email and password.
- Dashboard: Once logged in, you will be redirected to the dashboard where you can see your name.
-
Logout:
To logout, click on the "Logout" link.
connections.js
: Contains MongoDB connection setup.models/model.js
: Defines the User model schema.middleWares/Iplogger.js
: Middleware for logging IP addresses.middleWares/requireLogin.js
: Middleware for requiring login to access certain routes.public
: Contains static files (e.g., CSS, images).views
: Contains EJS templates for rendering HTML views.app.js
: Main entry point of the application.
Contributions are welcome! If you have any ideas, suggestions, or bug fixes, feel free to open an issue or submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.