🚀 Patch auto

This commit is contained in:
karim hassan
2025-08-24 23:00:40 +00:00
parent 92e6afff00
commit f1103d67a0
1314 changed files with 2511 additions and 562 deletions

View File

@@ -0,0 +1,14 @@
import jwt from 'jsonwebtoken';
export function requireAuth(req, res, next) {
try {
const h = req.headers.authorization || '';
const token = h.startsWith('Bearer ') ? h.slice(7) : '';
if (!token) return res.status(401).json({ error: 'missing_token' });
const decoded = jwt.verify(token, process.env.JWT_SECRET || 'supersecret');
req.user = decoded;
next();
} catch (e) {
res.status(401).json({ error: 'invalid_token' });
}
}