Skip to content

Commit

Permalink
Merge pull request #83 from aiibe/fastify-session-fix-isExpired-rollback
Browse files Browse the repository at this point in the history
Fix crash session.isExpired() is not a function
  • Loading branch information
SerayaEryn authored Nov 18, 2019
2 parents 2473a07 + 9f6b421 commit 3063e7d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
2 changes: 1 addition & 1 deletion lib/fastifySession.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function preValidation (options) {
newSession(secret, request, cookieOpts, done)
return
}
if (session.isExpired()) {
if (session && session.expires && session.expires <= Date.now()) {
options.store.destroy(sessionId, getDestroyCallback(secret, request, reply, done, cookieOpts))
return
}
Expand Down
4 changes: 0 additions & 4 deletions lib/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ module.exports = class Session {
this.encryptedSessionId = this[sign]()
}

isExpired () {
return this.expires != null && this.expires <= Date.now()
}

[addDataToSession] (prevSession) {
for (const key in prevSession) {
if (!['expires', 'cookie'].includes(key)) {
Expand Down

0 comments on commit 3063e7d

Please sign in to comment.