Skip to content

aryanathane/MERN-Auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” MERN-Auth

A clean, full-stack authentication system β€” register, login, verify, reset. All secured with JWT in cookies.

⚑ Tech Stack

Frontend Backend Database Auth Email
React Node.js PostgreSQL JWT (Cookies) Nodemailer
Tailwind CSS Express Sequelize / Prisma bcrypt

✨ Features

  • πŸ”‘ Register & Login
  • πŸ›‘οΈ JWT stored in httpOnly cookies
  • πŸ”’ Protected routes
  • πŸ“§ Email Verification on signup
  • πŸ”„ Forgot & Reset Password via email
  • πŸšͺ Logout with cookie clearing

πŸš€ Getting Started

# 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 dev

πŸ”§ Environment Variables

server/.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.

πŸ“ Project Structure

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

πŸ“Œ API Routes

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)

πŸ“„ License

MIT Β© aryanathane

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages