Skip to content

User Authentication with OTP Verification in MERN Stack

Notifications You must be signed in to change notification settings

naumanch969/otp-authentication

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

OTP Authentication System

This repository contains the code for implementing a complete OTP (One-Time Password) authentication system using the MERN (MongoDB, Express.js, React.js, Node.js) stack. With this system, users can register for an account, verify their identity using OTP sent to their mobile number or email, and securely authenticate themselves.

Features

  • User Registration
  • OTP Verification
  • User Authentication
  • Change Password
  • Password Encryption
  • Token-Based Authentication
  • Responsive UI

Tech Stack

  • Frontend:

    • React.js
    • React Router
    • Axios
    • Material-UI
  • Backend:

    • Node.js
    • Express.js
    • MongoDB
    • Mongoose
    • JSON Web Tokens (JWT)
    • Nodemailer (for email OTP)

Setup Instructions

  1. Clone the Repository: Use git clone to clone this repository to your local machine.

    git clone https://github.com/naumanch969/otp-authentication.git
  2. Backend Setup:

    • Navigate to the backend directory:
      cd backend
    • Install dependencies:
      npm install
    • Configure environment variables:
      • Create a .env file based on the provided .env.example template.
      • Update the environment variables with your MongoDB connection URI, JWT secret key, and Twilio API credentials (if using SMS OTP).
    • Start the backend server:
      npm start
  3. Frontend Setup:

    • Navigate to the frontend directory:
      cd frontend
    • Install dependencies:
      npm install
    • Start the frontend development server:
      npm start
  4. Access the Application:

    • Once both the backend and frontend servers are running, you can access the application at http://localhost:3000 in your web browser.

Feel free to explore, test, and customize this OTP authentication system according to your requirements. If you encounter any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request.

Happy coding! 🚀