Welcome to the Password Reset and User Management API! This repository contains the source code and documentation for a Node.js API built with Express.js for managing users and handling password resets. The API utilizes various libraries and tools including dotenv, cors, bcryptjs, jsonwebtoken, nodemon, nodemailer, mongoose, and is deployed on Render.
- User Authentication: Implements user authentication using bcryptjs for hashing passwords and jsonwebtoken for generating and verifying authentication tokens.
- User Registration: Allows users to register by providing their email and password.
- User Login: Enables registered users to log in with their email and password.
- Password Reset Request: Provides an endpoint for users to request a password reset by providing their email address.
- Secure Verification: Utilizes secure methods for verifying the identity of users requesting password resets.
- Token Generation: Generates unique tokens for password reset requests to prevent unauthorized access.
- Password Update: Allows users to securely update their passwords after successful verification.
- Email Notifications: Uses nodemailer to send email notifications for password reset requests.
- Database Integration: Integrates with MongoDB using mongoose for storing user data securely.
- Environment Variables: Utilizes dotenv for managing environment variables.
- Cross-Origin Resource Sharing (CORS): Implements CORS to allow requests from authorized domains.
To get started with the Password Reset and User Management API, follow these steps:
-
Clone the Repository: Clone this repository to your local machine using
(https://github.com/HarikaranSubramanian/NodeJsTask-4-Password-Reset-BE.git)
. -
Install Dependencies: Install the necessary dependencies by running
npm install
. -
Set Environment Variables: Create a
.env
file in the root directory and define environment variables such as database connection URI, email configuration, and JWT secret. -
Database Setup: Set up a MongoDB database either locally or using a cloud service like MongoDB Atlas. Update the
.env
file with the appropriate database connection URI. -
Start the Server: Start the server by running
npm start
ornpm run dev
if using nodemon for development. The API will be accessible at the specified port (default is 5000). -
Testing: Test the API endpoints using tools like Postman or curl to ensure everything is working as expected.
-
Deployment: Deploy the API to Render or any other hosting provider by following their deployment instructions. You can find the deployed application here.
POST /register
: Register a new user.GET /list-all-users
: List all users.POST /login
: Log in with existing credentials.POST /forgotPassword
: Request a password reset.POST /resetPassword
: Reset password using the provided token.
Contributions are welcome! If you'd like to contribute to the project, please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature/feature-name
). - Make your changes.
- Commit your changes (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature/feature-name
). - Create a new Pull Request.