From 4ccc4ccc6dbc14ac78294b396e7328b8475dcc75 Mon Sep 17 00:00:00 2001 From: Hamish Hossack Date: Tue, 18 Aug 2020 09:49:16 +0100 Subject: [PATCH] feat: add cookie opts to client-sessions --- lib/handler.js | 3 ++- test/unit/handler.js | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/handler.js b/lib/handler.js index 30f3528..77b1b20 100644 --- a/lib/handler.js +++ b/lib/handler.js @@ -56,7 +56,8 @@ Handler.prototype.createSession = function createSession () { const session = sessions({ cookieName: this.opts.sessionName, secret: this.opts.secretKey, - duration: 24 * 60 * 60 * 1000 + duration: 24 * 60 * 60 * 1000, + cookie: this.opts.cookie || {} }) return new Promise(resolve => session(this.req, this.res, resolve)) } diff --git a/test/unit/handler.js b/test/unit/handler.js index 87885da..af37a60 100644 --- a/test/unit/handler.js +++ b/test/unit/handler.js @@ -39,6 +39,9 @@ beforeEach(() => { accessTokenPath: '/token2', sessionName: 'testSession', secretKey: 'sekret', + cookie: { + sameSite: 'lax' + }, fetchUser: jest.fn(() => user), onLogout: jest.fn(() => {}) } @@ -139,7 +142,8 @@ describe('Handler', () => { expect(sessions).toBeCalledWith({ duration: 86400000, // 1 day, cookieName: options.sessionName, - secret: options.secretKey + secret: options.secretKey, + cookie: options.cookie }) })