Skip to content

Instantly share code, notes, and snippets.

@muhammed-mukthar
Created October 21, 2022 13:49
Show Gist options
  • Save muhammed-mukthar/b83afa6b5693023e2d80c7838e1e0c7c to your computer and use it in GitHub Desktop.
Save muhammed-mukthar/b83afa6b5693023e2d80c7838e1e0c7c to your computer and use it in GitHub Desktop.
const jwt = require("jsonwebtoken");//require jwt
//setting token
const accessToken = jwt.sign(
{
id: AdminLogin._id,//data you want incluede
},
process.env.JWT_SEC,
{ expiresIn: "3d" }
);
//verifying token
jwt.verify(accessToken, process.env.JWT_SEC, (err, user) => {
if (err) {
//error handling code here
}else{
next();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment