import express from 'express';
import {
  register,
  login,
  getProfile,
  getAllUsers,
  forgotPassword,   // ✅ NEW
  resetPassword,    // ✅ NEW
  changePassword,   // ✅ NEW
} from '../controllers/authController.js';
import { authenticateToken } from '../middleware/auth.js';

const router = express.Router();

// ── Existing routes ──────────────────────────────────────────
router.post('/register',        register);
router.post('/login',           login);
router.get ('/profile',         authenticateToken, getProfile);
router.get ('/users',           authenticateToken, getAllUsers);

// ── ✅ New password routes ────────────────────────────────────

// Step 1: Email bhejo → token milega
router.post('/forgot-password', forgotPassword);

// Step 2: Token se naya password set karo
router.post('/reset-password',  resetPassword);

// Change password (logged-in user ke liye)
router.post('/change-password', authenticateToken, changePassword);

export default router;