Fix for issue #5334. SessionStore now uses the correct value

v1.18.x
Dominic Lennon 8 years ago
parent 6b2dde02b5
commit d248ef95cd

@ -9,6 +9,7 @@
var session = require('express-session');
var _ = require('underscore');
var semver = require('semver');
var meta = require('../meta');
var db;
_.mixin(require('underscore.deep'));
@ -111,23 +112,28 @@
if (err) {
return callback(err);
}
createSessionStore();
callback();
});
} else {
winston.warn('You have no mongo password setup!');
createSessionStore();
callback();
}
});
};
function createSessionStore() {
module.initSessionStore = function (callback) {
var meta = require('../meta');
var sessionStore;
if (nconf.get('redis')) {
sessionStore = require('connect-redis')(session);
var rdb = require('./redis');
rdb.client = rdb.connect();
var ttlDays = 1000 * 60 * 60 * 24 * (parseInt(meta.config.loginDays, 10) || 14);
module.sessionStore = new sessionStore({
client: rdb.client,
ttl: 60 * 60 * 24 * 14
ttl: ttlDays
});
} else if (nconf.get('mongo')) {
sessionStore = require('connect-mongo')(session);
@ -135,9 +141,8 @@
db: db
});
}
callback();
}
});
};
module.createIndices = function (callback) {

@ -38,7 +38,6 @@
module.init = function (callback) {
try {
redis = require('redis');
connectRedis = require('connect-redis')(session);
} catch (err) {
winston.error('Unable to initialize Redis! Is Redis installed? Error :' + err.message);
process.exit();
@ -48,11 +47,6 @@
module.client = redisClient;
module.sessionStore = new connectRedis({
client: redisClient,
ttl: 60 * 60 * 24 * 14
});
require('./redis/main')(redisClient, module);
require('./redis/hash')(redisClient, module);
require('./redis/sets')(redisClient, module);
@ -64,6 +58,22 @@
}
};
module.initSessionStore = function (callback) {
var meta = require('../meta');
connectRedis = require('connect-redis')(session);
var ttlDays = 1000 * 60 * 60 * 24 * (parseInt(meta.config.loginDays, 10) || 14);
module.sessionStore = new connectRedis({
client: redisClient,
ttl: ttlDays
});
if (typeof callback === 'function') {
callback();
}
};
module.connect = function (options) {
var redis_socket_or_host = nconf.get('redis:host');
var cxn;

@ -40,6 +40,9 @@ start.start = function () {
next(err);
});
},
function(next) {
db.initSessionStore(next);
},
function (next) {
var webserver = require('./webserver');
require('./socket.io').init(webserver.server);

Loading…
Cancel
Save