Skip to content

Instantly share code, notes, and snippets.

@shiningabdul
Created September 12, 2017 04:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shiningabdul/2efd84cf479647e7627cef4928b63e04 to your computer and use it in GitHub Desktop.
Save shiningabdul/2efd84cf479647e7627cef4928b63e04 to your computer and use it in GitHub Desktop.
const secretForJWT = "thisIsAReallyGoodSecretNo";
const jwtExpireTimeInSeconds = 60*60;
generate_jwt = function(tokenData) {
return jwt.sign(tokenData, secretForJWT, {
expiresIn: jwtExpireTimeInSeconds
});
};
verify_jwt = function(token) {
try {
return jwt.verify(token, secretForJWT);
} catch(error) {
console.error("Error decoding jwt: %s", error);
}
return null;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment