From 597a9063e5fd4c11e926669c2d2e335ca329f9b9 Mon Sep 17 00:00:00 2001 From: azivner Date: Sun, 15 Oct 2017 17:07:34 -0400 Subject: [PATCH] filestore for sessions --- node/app.js | 7 ++++++- node/package.json | 1 + node/utils.js | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/node/app.js b/node/app.js index 46f08fff2..674ab2f09 100644 --- a/node/app.js +++ b/node/app.js @@ -6,6 +6,7 @@ const cookieParser = require('cookie-parser'); const bodyParser = require('body-parser'); const helmet = require('helmet'); const session = require('express-session'); +const FileStore = require('session-file-store')(session); const appRoute = require('./routes/app'); const loginRoute = require('./routes/login'); @@ -48,7 +49,11 @@ app.use(session({ // path: "/", httpOnly: true, maxAge: 1800000 - } + }, + store: new FileStore({ + ttl: 3600, + path: '../sessions' + }) })); // uncomment after placing your favicon in /public //app.use(favicon(path.join(__dirname, 'public', 'favicon.ico'))); diff --git a/node/package.json b/node/package.json index 0925c8738..5947455a9 100644 --- a/node/package.json +++ b/node/package.json @@ -19,6 +19,7 @@ "morgan": "~1.9.0", "scrypt": "^6.0.3", "serve-favicon": "~2.4.5", + "session-file-store": "^1.1.2", "sqlite": "^2.8.0" } } diff --git a/node/utils.js b/node/utils.js index 7bd53a02e..31f05ff95 100644 --- a/node/utils.js +++ b/node/utils.js @@ -19,7 +19,7 @@ function randomString(length, chars) { } function nowTimestamp() { - return Date.now() / 1000; + return Math.floor(Date.now() / 1000); } function toBase64(plainText) {