secureAuth is a powerful authentication system designed for modern web applications. Utilizing JWT (JSON Web Tokens), nodemailer for email services, and MongoDB as a database, this system provides a comprehensive solution for user authentication. It includes features like registration, login, email verification, and password reset functionality.
- User Registration and Login System
- Email Verification on Registration
- Password Reset Functionality
- JWT for secure and efficient authentication
- MongoDB for robust data storage
- Node.js
- Express.js (REST API Framework)
- MongoDB (Database)
- bcrypt (Password Hashing)
- JWT (JSON Web Tokens)
- nodemailer (Email Service)
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- Node.js
- MongoDB
- Git (Optional)
- Clone the Repository (Optional)
git clone https://github.com/yourusername/secureAuth.git
cd secureAuth
- Install Dependencies
npm install
- Environment Setup
Create a
.env
file in the root directory of the project and add the following:
PORT=YourPortNumber
MONGODB_URI=YourMongoDBURI
JWT=YourSecretKeyForJWT
GUSER=YourGmailUsername
GPASS=YourGmailPassword
- Run the server
npm run dev
The server will start on the port specified in your .env
file.
- User Registration
POST /auth/register
- User Login
POST /auth/login
- Email Verification
GET /auth/verify/:token
- Send Reset Password Email
GET /auth/resetpassword
- Reset Password
POST /auth/reset/:token
- User Registration
- Request Body
{ "name": "John Doe", "email": "[email protected]", "password": "password123" }
- Response Body ( Success )
{ "error": false, "success": true, "result": { "_id": "UserID", "name": "John Doe", "email": "[email protected]", "isVerified": false }, "message": "User created successfully, please check your email for verification." }
- User Login
- Request Body
{ "email": "[email protected]", "password": "password123" }
- Response Body ( Success )
{ "accessToken": "GeneratedJWTToken", "userID": "UserID", "message": "Logged In Successfully" }
- Email Verification
- Request Body
{}
- Response Body ( Success )
{ "error": false, "message": "Email Verified Successfully" }
- Send Reset Password Email
- Request Header
{ "Authorization": "Bearer GeneratedJWTToken" }
- Response Body ( Success )
{ "error": false, "message": "Password Reset Link Successfully Sent." }
- Reset Password
- Request Header
{ "newPassword": "newPassword123" }
- Response Body ( Success )
{ "error": false, "message": "Password Changed Successfully" }
To customize secureAuth, modify the controllers, models, or routes according to your project's requirements. The MVC pattern makes it easy to adapt and extend.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License - see the LICENSE.md file for details.