Separated weight tracking

This commit is contained in:
AG
2025-11-29 12:13:12 +02:00
parent 78930f6b80
commit d86abd6b1b
11 changed files with 300 additions and 22 deletions

View File

@@ -0,0 +1,21 @@
import { Request, Response, NextFunction } from 'express';
import jwt from 'jsonwebtoken';
const JWT_SECRET = process.env.JWT_SECRET || 'secret';
export const authenticateToken = (req: Request, res: Response, next: NextFunction) => {
const authHeader = req.headers['authorization'];
const token = authHeader && authHeader.split(' ')[1];
if (!token) {
return res.sendStatus(401);
}
jwt.verify(token, JWT_SECRET, (err: any, user: any) => {
if (err) {
return res.sendStatus(403);
}
(req as any).user = user;
next();
});
};