A simple OTP (One-Time Password) based authentication system built using Node.js, Express, and MongoDB.
- User registration with email verification using OTP
- User login with OTP verification
- User profile route with authentication
-
Clone the repository:
git clone https://github.com/adarsh-2425/OTP-based-Authentication-System.git
-
Install dependencies:
cd OTP-based-Authentication-System npm install
- Configure environment variables:
Create a .env file in the root directory and set the following variables:
MONGODB_URI=your-mongodb-uri
- Run the application:
npm start
- POST auth/registration: Register a new user and verify their email using OTP.
- POST auth/login: Login with OTP verification.
- GET auth/profile: Get user profile with authentication.
- Node.js
- Express.js
- MongoDB
- Mongoose
- Nodemailer (for email OTP)
- JWT (JSON Web Tokens)
-
Register a new user by providing their email. An OTP will be sent to their email for verification. Use the route
/verify-otp/registration
. -
Login using the registered email and the OTP received in their email. Use the route
/verify-otp/login
. -
Access the profile route (
/profile
) to get user information. Requires authentication.
This project is licensed under the MIT License - see the LICENSE file for details.