fix(tokens): add requireAuth middleware to token routes

Token CRUD endpoints had no authentication guard.  Without it,
unauthenticated requests could reach the handler — GET would return
empty results silently, and POST could attempt to insert a token with
user_id = NULL.  All other route files in this codebase apply
requireAuth explicitly; tokens.js was simply missing it.
This commit is contained in:
Zac Gaetano 2026-05-19 00:07:41 -04:00
parent 0ea8d7ce33
commit 4f8964e807

View file

@ -8,8 +8,10 @@
import express from 'express';
import crypto from 'crypto';
import pool from '../db/pool.js';
import { requireAuth } from '../middleware/auth.js';
const router = express.Router();
router.use(requireAuth);
// Helper: get current user ID from session or req.user
const userId = req => req.user?.id || req.session?.userId;