https://github.com/thisiskhizar/node-auth-system
A secure, reusable Node.js auth system with email verification and JWT support.
https://github.com/thisiskhizar/node-auth-system
auth-system authentication express jwt mongodb nodejs rest-api
Last synced: 15 days ago
JSON representation
A secure, reusable Node.js auth system with email verification and JWT support.
- Host: GitHub
- URL: https://github.com/thisiskhizar/node-auth-system
- Owner: thisiskhizar
- License: mit
- Created: 2025-03-23T17:36:48.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2025-04-01T10:25:11.000Z (about 2 months ago)
- Last Synced: 2025-04-01T10:31:31.494Z (about 2 months ago)
- Topics: auth-system, authentication, express, jwt, mongodb, nodejs, rest-api
- Language: JavaScript
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Node Auth System
A reusable and secure Node.js authentication system using Express, JWT, and MongoDB.

## Features
- Email verification (via token or code)
- Login with access and refresh tokens
- Token refresh and logout
- Password reset via email
- Middleware-protected routes## Tech Stack
- Node.js + Express
- MongoDB + Mongoose
- JWT, bcrypt, cookie-parser
- dotenv, helmet, cors, morgan## Installation
```bash
# Clone the repo
git clone https://github.com/your-username/node-auth-system.git
cd node-auth-system# Install dependencies
npm install# Setup environment variables
cp .env.example .env
# Fill in the required values in .env# Start the dev server
npm run dev
```## API Endpoints
All endpoints are prefixed with: `/api/v1/auth`
| Method | Endpoint | Description |
|--------|----------------------|--------------------------------------|
| POST | `/register` | Register new user |
| GET | `/verify/:token` | Verify email via token |
| POST | `/verify-code` | Verify email via 6-digit code |
| POST | `/login` | Login and receive tokens |
| POST | `/refresh-token` | Refresh JWT access token |
| POST | `/logout` | Logout and clear refresh token |
| POST | `/forgot-password` | Request password reset |
| POST | `/reset-password/:token` | Reset password using token |
| GET | `/check-auth` | Protected route — returns user info |## Customization
- Plug into any frontend — React, Vue, mobile, etc.
- Hook up your preferred email provider in `mail.service.js`
- Extend user model or controller logic as needed