32 lines
808 B
JavaScript
32 lines
808 B
JavaScript
const { verify } = require('jsonwebtoken');
|
|
|
|
module.exports={
|
|
checkToken : (req,res,next)=>{
|
|
let token=req.get('authorization');
|
|
if(token)
|
|
{
|
|
token=token.slice(7);
|
|
verify(token,process.env.JWT_SECRET_KEY,(err,decoded)=>{
|
|
if(err)
|
|
{
|
|
res.json({
|
|
"code":"2",
|
|
"message":"This mobile number is register on another device please check"
|
|
})
|
|
}
|
|
else
|
|
{
|
|
next();
|
|
}
|
|
|
|
});
|
|
}
|
|
else
|
|
{
|
|
res.json({
|
|
"success":"0",
|
|
"message":"Unauthorized user Credentials"
|
|
})
|
|
}
|
|
}
|
|
} |