// middleware/publicAuth.js
const { verifyPublicEventToken } = require('../utils/publicJwt');

module.exports = (req, res, next) => {
  const auth = req.headers.authorization;
  if (!auth || !auth.startsWith('Bearer ')) return res.status(401).json({ message: '토큰 필요' });
  try {
    req.publicAuth = verifyPublicEventToken(auth.slice(7));
    next();
  } catch (e) {
    return res.status(401).json({ message: '토큰 인증 실패' });
  }
};
