A complete authentication system built with the MERN (MongoDB, Express.js, React, Node.js) stack. This system includes user registration, login, email verification via OTP, and password reset via email and OTP.
- User Signup with Email Verification (OTP-based)
- User Login with JWT Authentication
- Email Verification via OTP
- Password Reset using OTP and Email
- Secure Token-based Authentication
- MongoDB for storing user credentials
- Express.js as the backend framework
- React.js for the frontend
- Node.js for handling server-side logic
- Frontend: React.js, Axios, Tailwind CSS (optional)
- Backend: Node.js, Express.js
- Database: MongoDB (Mongoose ORM)
- Authentication: JWT (JSON Web Tokens), bcrypt.js
- Email Service: Nodemailer
Ensure you have the following installed on your system:
- Node.js (latest stable version)
- MongoDB (installed locally or using a cloud service like MongoDB Atlas)
- Git
git clone https://github.com/yourusername/mern-auth-system.git
cd Complete_MERN_Authenticationcd server
npm installcd ../client
npm installCreate a .env file in the backend directory and add the following:
PORT=5000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret
EMAIL_USER=your_email@example.com
EMAIL_PASS=your_email_passwordcd server
npm run servercd client
npm run dev- POST
/api/auth/register- Register a new user - POST
/api/auth/login- Login with email and password - POST
/api/auth/logout- Logout from the system - POST
/api/auth/send-verify-otp- Request email verify OTP - POST
/api/auth/verify-account- Verify email via OTP - GET
/api/auth/is-auth- check wether the user is authenticated - POST
/api/auth/send-reset-otp- Request password reset OTP - POST
/api/auth/reset-password- Reset password using OTP - GET
/api/user/data- get user data
mern-auth-system/
│── backend/
│ ├── config/
│ ├── controllers/
│ ├── models/
│ ├── routes/
│ ├── middleware/
│ ├── server.js
│
│── frontend/
│ ├── src/
│ ├── components/
| ├── assets/
| ├── context/
│ ├── pages/
│ ├── App.jsx
│ ├── main.jsx
| ├── index.css
Feel free to contribute to this project by submitting issues or pull requests.