Summary Table

Categories Total Count
PII 0
URL 0
DNS 0
EKL 0
IP 0
PORT 0
VsID 0
CF 0
AI 0
VPD 0
PL 0
Other 0

File Content

const fs = require('fs')
const jwt = require('jsonwebtoken');
const path = require('path');
const RSA_PUBLIC_KEY = fs.readFileSync(path.join(__dirname, '/../../../keys/public.key'),'utf8');
const AuthGuardMiddleware = (req, res, next) => {
const token = req.cookies.JWT;
if (token) {
jwt.verify(token,RSA_PUBLIC_KEY,{algorithms: ['RS256']}, (err, decoded) => {
if (err) {
return res.status(401).json(`un-authorized invalid token ${err}`);
}
next();
})
} else {
res.status(401).json('un-authorized invalid token')
}



}

module.exports = AuthGuardMiddleware;