Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Phara0h committed Nov 5, 2021
1 parent d3d94e1 commit cc3f35d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion index.js
Expand Up @@ -6,8 +6,11 @@ var Session = require('./session.js');
const cookieSignature = require('cookie-signature');
const crypto = require('crypto');

var sessionOptions = null

function session(fastify, options, next) {
ensureDefaults(options).then((options) => {
sessionOptions = options;
fastify.addHook('onRequest', (req, res, done) => {
req.sessionStore = options.store;
req.session = {};
Expand Down Expand Up @@ -155,7 +158,7 @@ function destroySession(done) {
});
}
function createSession(id, data) {
this.session = new Session(options.secret, id, data, Date.now() + options.cookie.maxAge * 1000);
this.session = new Session(sessionOptions.secret, id, data, Date.now() + sessionOptions.cookie.maxAge * 1000);
}

function ensureDefaults(options) {
Expand Down

0 comments on commit cc3f35d

Please sign in to comment.