- 9 endpoints métier : synthese, alertes, en-service, en-cours, par-region, clotures, pilotage-proactif, matrice-risque - Exports PDF (tous rôles) / XLSX PPTX DOCX (superadmin) - services/calc.js : helpers normalisés partagés - services/export-pdf.js : PDF async PDFKit par vue - Thème McKinsey (#1C2B4B / bleu pétrole / gris sobre) - Boutons XLSX/DOCX front (superadmin uniquement) - BASEROW_API_URL → https://baserow.bolbol.tn/api/ - dotenv override: true Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
18 lines
468 B
JavaScript
18 lines
468 B
JavaScript
const jwt = require('jsonwebtoken');
|
|
|
|
module.exports = function authMiddleware(req, res, next) {
|
|
const header = req.headers['authorization'] || '';
|
|
const token = header.startsWith('Bearer ') ? header.slice(7) : null;
|
|
|
|
if (!token) {
|
|
return res.status(401).json({ error: 'Token manquant' });
|
|
}
|
|
|
|
try {
|
|
req.user = jwt.verify(token, process.env.JWT_SECRET);
|
|
next();
|
|
} catch {
|
|
res.status(401).json({ error: 'Token invalide ou expiré' });
|
|
}
|
|
};
|