const { verify, decode } = require("jsonwebtoken");


module.exports = {
    checkToken: (req, res, next) => {
        let token = req.get('authorization');
        if(token){
            token = token.slice(7);
            verify(token, "qwe1234",(err, decoded) => {
                if(err){
                    res.status(401).json({status: false, message:"Invalid Token"});
                } else {
                    next();
                }
            });
        } else {
            res.status(401).json({status: false, message: "Access Denied Unauthorized User"});
        }
    }
}