A clean, full-stack authentication system β register, login, verify, reset. All secured with JWT in cookies.
| Frontend | Backend | Database | Auth | |
|---|---|---|---|---|
| React | Node.js | PostgreSQL | JWT (Cookies) | Nodemailer |
| Tailwind CSS | Express | Sequelize / Prisma | bcrypt |
- π Register & Login
- π‘οΈ JWT stored in httpOnly cookies
- π Protected routes
- π§ Email Verification on signup
- π Forgot & Reset Password via email
- πͺ Logout with cookie clearing
# Clone
git clone https://github.com/aryanathane/MERN-Auth.git
cd MERN-Auth
# Backend
cd server
npm install
npm start
# Frontend (new terminal)
cd ../client
npm install
npm run devserver/.env
PORT=5000
DATABASE_URL=postgresql://user:pass@localhost:5432/dbname
JWT_SECRET=your_jwt_secret
JWT_EXPIRY=7d
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your_email@gmail.com
SMTP_PASS=your_app_password
CLIENT_URL=http://localhost:3000π‘ Using Gmail? Enable 2FA and use an App Password.
MERN-Auth/
βββ client/ # React + Tailwind frontend
βββ server/ # Express + PostgreSQL backend
βββ routes/ # Auth routes
βββ middleware/ # JWT & auth middleware
βββ models/ # DB models
βββ controllers/ # Logic handlers
βββ utils/ # Email & token helpers
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/register |
Register + send verification email |
| POST | /api/auth/login |
Login + set JWT cookie |
| POST | /api/auth/logout |
Clear JWT cookie |
| GET | /api/auth/verify/:token |
Verify email |
| POST | /api/auth/forgot-password |
Send reset email |
| POST | /api/auth/reset-password/:token |
Reset password |
| GET | /api/auth/me |
Get current user (protected) |
MIT Β© aryanathane