-
Matt Kirby authoredMatt Kirby authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
auth.js 415 B
import jwt from 'jsonwebtoken';
import ENV from '../config.js'
export default async function Auth(req, res, next){
try {
const token = req.headers.authorization.split(" ")[1];
const decodedToken = await jwt.verify(token, ENV.JWT_SECRET);
req.user = decodedToken;
next();
} catch (error) {
res.status(401).json({ error : "Authentication Failed!"})
}
}