Skip to content

Commit

Permalink
do not add session id to session
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Jun 29, 2022
1 parent 86ac8fc commit a371c36
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ module.exports = class Session {

[addDataToSession] (prevSession) {
for (const key in prevSession) {
if (!['expires', 'cookie'].includes(key)) {
if (!['expires', 'cookie', 'sessionId', 'encryptedSessionId'].includes(key)) {
this[key] = prevSession[key]
}
}
Expand Down
2 changes: 2 additions & 0 deletions test/base.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ test('should set session cookie using the default cookie name', async (t) => {
fastify.addHook('onRequest', (request, reply, done) => {
request.sessionStore.set('Qk_XT2K7-clT-x1tVvoY6tIQ83iP72KN', {
expires: Date.now() + 1000,
sessionId: 'Qk_XT2K7-clT-x1tVvoY6tIQ83iP72KN',
cookie: { secure: true, httpOnly: true, path: '/' }
}, done)
})
Expand Down Expand Up @@ -129,6 +130,7 @@ test('should create new session on expired session', async (t) => {
fastify.addHook('onRequest', (request, reply, done) => {
request.sessionStore.set('Qk_XT2K7-clT-x1tVvoY6tIQ83iP72KN', {
expires: Date.now() - 1000,
sessionId: 'Qk_XT2K7-clT-x1tVvoY6tIQ83iP72KN',
cookie: { secure: true, httpOnly: true, path: '/' }
}, done)
})
Expand Down

0 comments on commit a371c36

Please sign in to comment.