Created
December 15, 2015 23:42
-
-
Save thebergamo/f572b70fb49b25adb179 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
function getToken (user) { | |
const secretKey = process.env.JWT || ‘stubJWT’; | |
return jwt.sign({ id: user._id, roles: user.roles }, secretKey, {expiresIn: ‘18h’}); | |
} |
That's a good question... it's been 6 years since it's originally posted :p
So I do not remember, but it seems that based on your user it would generate a JWT for you with expiration in 18h and will give you the user roles.
That was part of blog post of mine, I would suggest you to take a look: https://medium.com/@thedon/scoping-roles-in-hapi-1f3ab86d6576
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How do I use this...