Created
October 21, 2022 13:49
-
-
Save muhammed-mukthar/b83afa6b5693023e2d80c7838e1e0c7c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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