MCPcopy Index your code
hub / github.com/Packstack-Tech/packstack / authenticate

Function authenticate

api/utils/jwt.js:25–39  ·  view source on GitHub ↗
(req, res, next)

Source from the content-addressed store, hash-verified

23};
24
25export const authenticate = (req, res, next) => {
26 const authHeader = req.get('authorization');
27 if (!authHeader) {
28 return res.sendStatus(401);
29 }
30
31 const token = authHeader.split(' ')[1];
32 const decoded = jwt.verify(token, process.env.JWT_SECRET);
33 models.User.findOne({where: {id: decoded.id}})
34 .then(user => {
35 req.user = user;
36 next();
37 })
38 .catch(() => res.sendStatus(400));
39};

Callers

nothing calls this directly

Calls 1

getMethod · 0.80

Tested by

no test coverage detected