const jwt = require('jsonwebtoken')

let checkAuth = (req,res,next)=>{
   let  token = req.get('token');
    
jwt.verify(token,"api finanzas mdchaparror @4050#",(err,decoded)=>{

    if(err){
        return res.status(401).json({
            status:"Fail",
            error:err
        })
    }

req.userData = decoded.userData;
next();
})



}

module.exports = {checkAuth};