const express = require('express');
const router = express.Router();
const { stoeberhundefuehrerLogin, setStoeberhundefuehrerPassword, generateInviteToken, updateStoeberhundefuehrerSelf, getStoeberhundefuehrerSelf } = require('../controllers/stoeberhundefuehrerController');
const { authenticateToken } = require('../middleware/auth');
const { authenticateStoeberhundefuehrer } = require('../middleware/stoeberhundefuehrerAuth');
const { inviteLimiter } = require('../middleware/rateLimiter');

// Public
router.post('/login', stoeberhundefuehrerLogin);
router.post('/set-password', inviteLimiter, setStoeberhundefuehrerPassword);

// Admin only — generate a one-time invite token so a Stöberhundeführer can set their password
router.post('/:id/invite-token', authenticateToken, generateInviteToken);

// Authenticated Stöberhundeführer only
router.get('/me', authenticateStoeberhundefuehrer, getStoeberhundefuehrerSelf);
router.put('/me', authenticateStoeberhundefuehrer, updateStoeberhundefuehrerSelf);

module.exports = router;
