This repository contains code for a bookstore management system. The system provides
- Node.js
- Express.js
- MongoDB
- JSON Web Tokens (JWT)
- Multer (for file uploads)
- EJS (for rendering views)
- Nodemailer (for sending transactional emails)
- User Signup: Allows users to register by providing their email address and choosing a username.
- Email Verification: Sends a verification email containing a unique token to the user's email address for validation.
- Login: Allows registered users to log in using their email address and password.
- JWT Authentication: Generates JSON Web Tokens (JWT) upon successful login for secure authentication of subsequent requests.
- Logout: Logs the user out of the system, invalidating their current session.
- User Profile Rendering: Displays user-specific information such as username and profile details.
- The function
accountretrieves user account information and renders it on a webpage, including - user details, user info, and associated books.
-* @param {Object} req - The request object representing the HTTP request made by the client. -* @param {Object} res - The response object used to send a response back to the client.
-* The req parameter contains information such as the request method (req.method), request parameters (req.params),
and other details about the request.
-* The res parameter is used to send data, status codes, and render views in response to client requests.
-* In this code snippet, the function checks if the request method is a GET and proceeds to retrieve user account information and render it on a webpage. -*
This code snippet defines a JavaScript object named HomeController, which contains several methods for handling different routes and actions in a web application.
-* This code snippet defines a JavaScript object named HomeController which contains several methods
-* for handling different routes and actions in a web application. Here is a breakdown of what each
-* method does:
- email: Stores the email address of the user. Used for signup, login, verification, and identification in the database.
- UserName: Stores the username of the user. Used for signup, login, and displaying user-specific information.
- emailtoken: A unique token generated for each user during signup. Used for email verification and validation.
- During signup, a random emailtoken is generated for each user.
- This token is sent to the user's email address for verification.
- Once the user clicks on the verification link containing the token, their email is verified.
To use this system, follow these steps:
- Clone the repository to your local machine.
- Install any required dependencies.
- Configure the database connection settings.
- AppEmail: Application email address for sending emails.
- AppPassword: Application-specific password for email authentication.
- MY_SECRET: Secret key for encryption and decryption.
- Run the application.
Contributions are welcome! If you find any bugs or want to suggest improvements, feel free to open an issue or submit a pull request.
This project is licensed under the MIT License.