function verifyJwt(req, next) {
        let token;
        if(req.get('authorization')) {
            token = req.get('authorization').split(' ')[1];
        } else {
            token = req.body.token || req.query.token || req.headers['x-access-token'];
        }
        if(!token) {
            return next(helpers.basicError("No token provided", 401));
        }
        return jwt.verify(token, process.env.TOKEN_SECRET, function(err, decoded) {      
            if (err) {
                if(err.message == "jwt expired") {
                    return next(helpers.basicError("Token expired", 401));
                }
                return next(helpers.basicError("Failed to authenticate token", 401));
            }
            return decoded;
        });
    }
// Checks for the JWT token in authorization header
Checks for the JWT token in authorization header
Checks for the JWT token in authorization header
function verifyJwt(req, next) {
        let token;
        if(req.get('authorization')) {
            token = req.get('authorization').split(' ')[1];
        } else {
            token = req.body.token || req.query.token || req.headers['x-access-token'];
        }
        if(!token) {
            return next(helpers.basicError("No token provided", 401));
        }
        return jwt.verify(token, process.env.TOKEN_SECRET, function(err, decoded) {      
            if (err) {
                if(err.message == "jwt expired") {
                    return next(helpers.basicError("Token expired", 401));
                }
                return next(helpers.basicError("Failed to authenticate token", 401));
            }
            return decoded;
        });
    }
function verifyJwt ( req , next ) { let token ; if ( req . get ( 'authorization' ) ) { token = req . get ( 'authorization' ) . split ( ' ' ) [ 1 ] ; } else { token = req . body . token || req . query . token || req . headers [ 'x-access-token' ] ; } if ( ! token ) { return next ( helpers . basicError ( "No token provided" , 401 ) ) ; } return jwt . verify ( token , process . env . TOKEN_SECRET , function ( err , decoded ) { if ( err ) { if ( err . message == "jwt expired" ) { return next ( helpers . basicError ( "Token expired" , 401 ) ) ; } return next ( helpers . basicError ( "Failed to authenticate token" , 401 ) ) ; } return decoded ; } ) ; }
Checks for the JWT token in authorization header
Checks for the JWT token in authorization header