(Login and Signup App using React.js, Node.js, and JWT)
- MongoDB is used as the database.
- Mongoose library is utilized for seamless interaction with MongoDB.
- The MongoDB connection string is securely stored in the
.env
file to keep sensitive data private.
- POST API for user registration has been successfully implemented.
- The Signup API incorporates JWT authentication for secure user registration.
- jsonwebtoken library is used to generate the JWT token upon successful signup.
- Password hashing is handled securely using the bcryptjs library.
- Email verification functionality is implemented using Nodemailer.
- Rate limiting is in place to prevent abuse during the signup process.
- Robust error handling is applied to manage different edge cases and improve user experience.
- API Endpoint:
http://localhost:5000/api/auth/register
- Clone the project from GitHub and navigate to the project directory.
- Open the terminal and run the command:
node server.js
- Open Postman and select the
POST
method. - Enter the URL:
http://localhost:5000/api/auth/register
. - Upon successful registration, you will receive a JWT token and an email verification link at the registered email address (check your spam folder).
- Click the verification link to confirm your email address and complete the registration process.
- POST API for user login has been successfully created.
- JWT authentication is integrated to ensure secure login.
- The jsonwebtoken library is used to generate a JWT token upon successful login.
- Email verification middleware ensures that only verified users can log in.
- Rate limiting is implemented to protect the login endpoint from abuse.
- Error handling is in place for failed login attempts.
- API Endpoint:
http://localhost:5000/api/auth/login
- Clone the project from GitHub and navigate to the project directory.
- Open the terminal and run the command:
node server.js
- Open Postman and select the
POST
method. - Enter the URL:
http://localhost:5000/api/auth/login
. - Upon successful login, a JWT token will be returned.
- Use this JWT token to access all JWT-secured API endpoints.
- Nodemailer is used to send a password reset link to the user's registered email address.
- JWT token is used to securely reset the password.
- The new password is hashed using bcrypt.js before saving it to the database.
- API Endpoint for requesting a password reset:
http://localhost:5000/api/auth/request-password-reset
- API Endpoint for resetting the password:
http://localhost:5000/api/auth/reset-password/:token
- Clone the project and navigate to the project directory.
- Open the terminal and run the command:
node server.js
- Open Postman and select the
POST
method. - Request the URL:
http://localhost:5000/api/auth/request-password-reset
. - You will receive a password reset link at your registered email address.
- Add the new password in the request body.
- Then, request the URL:
http://localhost:5000/api/auth/reset-password/:token
. - Replace
:token
with the token received in the email. - The new password will be hashed and stored securely.
- The backend server is deployed on Render Cloud Server for public access.
- The project has been uploaded to GitHub, and the repository is connected to Render for continuous deployment.
- Axios library is used to make API requests for the signup process.
- The React Icon library is utilized for icons, and React Router is used for routing and navigation.
- Users are prompted to enter username, email, password, and profile picture.
- A Terms and Conditions checkbox is included to ensure user consent during registration.
- After submitting the form, a welcome email with an email verification link is sent to the user's email.
- Axios is used to send API requests for logging the user in.
- The useState hook is employed to manage login credentials (username/email and password).
- A Forgot Password functionality is implemented. Clicking on "Forgot Password" navigates the user to the password reset page.
- Remember Me functionality is added, which stores the user's credentials in localStorage for future use.
- Clone the repository.
- Run
npm install
to install dependencies. - Set up environment variables in a
.env
file (e.g., MongoDB URI, JWT secret). - Run the command
node server.js
to start the backend server. - Test API endpoints using Postman.
- Clone the repository for the frontend.
- Run
npm install
to install dependencies. - Start the development server using
npm run dev
. - The frontend will be accessible at
http://localhost:5173
.