New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adjusting expiration time to be 7 days #78
Conversation
example/lib/helpers.js
Outdated
@@ -36,7 +36,7 @@ function generateToken(req, GUID, opts) { | |||
// By default, expire the token after 7 days. | |||
// NOTE: the value for 'exp' needs to be in seconds since | |||
// the epoch as per the spec! | |||
var expiresDefault = Math.floor(new Date().getTime()/1000) + 7*24*60*60; | |||
var expiresDefault = Math.floor(Date.now() + (1000 * 60 * 60 * 24 * 7)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expiresIn
is defined in seconds not Milliseconds.
see: https://www.npmjs.com/package/jsonwebtoken
and:
else if( url === '/logout') { app.logout(req, res, app.done); } // end session | ||
else if( url === '/exit') { app.exit(res); } // for testing ONLY | ||
else { app.notFound(res); } // 404 error | ||
var path = url.parse(req.url).pathname; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good plan. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emersonmellado thanks for this PR! the update to url/path is good. 👍
However the expiration time needs to be in seconds so you need to divide by 1000 before (or after) the multiplication. 😉
Wow. Thanks @nelsonic. I didn't know about this doc. Apparently they have a simpler way to set the Expiration by using a 7d notation. Check it out! :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emersonmellado thanks very much for making these updates. 🎉
No description provided.