(Authentication Complete Β· Payments Backend Ready Β· Frontend Payments WIP)
A production-ready authentication system built with the MERN stack (MongoDB, Express, React, Node.js), extended with a manual UPI-based payment approval system for premium access.
This project focuses on secure, cookie-based authentication, Google OAuth, email workflows, and a backend-complete admin-controlled payment system.
- Local Authentication (Email + Password)
- Google OAuth 2.0 Login
- JWT Access & Refresh Tokens
- HTTP-only cookie-based sessions
- Silent token refresh
- Secure logout & token revocation
- Email verification after registration
- Forgot / Reset password flow
- Token expiration handling
- Email templates with Nodemailer
- HTTP-only, SameSite cookies (XSS safe)
- Refresh token rotation
- Rate limiting on auth routes
- Helmet security headers
- OAuth CSRF-safe state validation
/meendpoint for authenticated user- Persistent login across reloads
- Auto logout on invalid refresh token
β οΈ Frontend payment UI is under development
- Manual UPI QR-based payments
- One-time & time-based plans
- UTR submission & deduplication
- Admin approval / rejection workflow
- Secure admin-only routes
- Access enforcement middleware
- Premium route protection
- Payment audit trail
- Frontend payment UI
- User payment dashboard
- Admin payment UI (table)
- List payments (filtered by status)
- Approve / reject payments
- Grant lifetime or time-based access
- Admin-only protected routes
- Node.js + Express
- MongoDB + Mongoose
- JWT (Access & Refresh Tokens)
- Google OAuth 2.0
- Nodemailer
- Helmet, CORS, Rate Limiting
- React (Vite)
- React Router v6
- Context API
- Axios (with interceptors)
- Tailwind CSS
Login / OAuth
β Access Token (15 min) stored in httpOnly cookie
β Refresh Token stored in DB + cookie
β Access expires
β Silent refresh (/refresh-token)
β Retry original request
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/register | Register & send verification email |
| POST | /api/auth/login | Login (rate limited) |
| GET | /api/auth/google | Start Google OAuth |
| GET | /api/auth/google/callback | OAuth callback |
| POST | /api/auth/verify-email/:token | Verify email |
| POST | /api/auth/forgot-password | Send reset email |
| POST | /api/auth/reset-password/:token | Reset password |
| POST | /api/auth/refresh-token | Refresh access token |
| POST | /api/auth/logout | Logout & revoke refresh token |
| GET | /api/auth/me | Get authenticated user |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/payment/intent | Generate UPI QR intent |
| POST | /api/payment/verify | Submit UTR |
| GET | /api/payment/admin/payments | List all payments (admin) |
| GET | /api/payment/admin/payments?status=PENDING | List pending payments |
| POST | /api/payment/admin/payments/:id/approve | Approve payment |
| POST | /api/payment/admin/payments/:id/reject | Reject payment |
backend
βββ server.js
βββ configuration/
β βββ db.js
β
βββ middlewares/
β βββ rate.limiter.js
β βββ token.verification.js
β
βββ modules/
β βββ auth/
β β βββ controllers/
β β βββ models/
β β βββ routers/
β β βββ validators/
β β
β βββ payment/
β βββ controllers/
β β βββ paymentIntent.controller.js
β β βββ paymentVerification.controller.js
β β βββ adminPayment.controller.js
β βββ middleware/
β β βββ access.middleware.js
β β βββ admin.middleware.js
β βββ models/
β β βββ payment.model.js
β βββ routers/
β βββ payment.routes.js
β
βββ utils/
βββ Emails/
frontend/src
βββ context/
β βββ AuthContext.jsx
β
βββ components/
β βββ RequireAuth.jsx
β βββ RedirectIfAuth.jsx
β βββ Loading.jsx
β
βββ pages/
β βββ Auth/
β βββ Home/
β βββ NotFound/
β
βββ services/
β βββ api.js
β βββ auth.service.js
β
βββ Routers/
βββ AppRouters.jsx
/admin/payments?page=1&limit=10
- Admin can provide reason
- User can view rejection message
- Table view
- Approve / Reject buttons
- Status filters
- Middleware / cron job
- Disable access after
endDate
- DB indexes (
status,userId) - Validation tightening
- RBAC upgrade path
- Auth system fully integrated with frontend
- Payment backend is stable & secure
- Frontend payment integration is in progress
- Manual approval avoids unsafe automation
- Ready for Docker & cloud deployment
MIT License