const express = require('express');
const router = express.Router();
const { register, login, getAllUsers, updateUserRole, getMe, verifyEmail, forgotPassword, resetPassword, deleteAccount, checkAvailability, changePassword, checkStudentDomain } = require('../controllers/authController');
const { protect, admin } = require('../middleware/authMiddleware');

router.post('/register', register);
router.post('/check-availability', checkAvailability);
router.post('/login', login);
router.get('/verify-email/:token', verifyEmail);
router.post('/forgot-password', forgotPassword);
router.post('/reset-password/:token', resetPassword);
router.get('/me', protect, getMe);
router.delete('/me', protect, deleteAccount);
router.post('/change-password', protect, changePassword);
router.get('/users', protect, admin, getAllUsers);
router.put('/users/:id/role', protect, admin, updateUserRole);

const adminSettingsController = require('../controllers/adminSettingsController');
const oauthController = require('../controllers/oauthController');

router.get('/config', adminSettingsController.getPublicConfig);

// OAuth Routes
router.get('/google', oauthController.googleAuth);
router.get('/google/callback', oauthController.googleCallback);
router.get('/linkedin', oauthController.linkedinAuth);
router.get('/linkedin/callback', oauthController.linkedinCallback);
router.post('/check-student-domain', checkStudentDomain);

module.exports = router;
