Merge branch 'master' into develop

v1.18.x
barisusakli 8 years ago
commit 38e16ca8f6

@ -116,9 +116,7 @@
var meta = require('../meta');
var sessionStore;
var ttlDays = 60 * 60 * 24 * (parseInt(meta.config.loginDays, 10) || 0);
var ttlSeconds = (parseInt(meta.config.loginSeconds, 10) || 0);
var ttl = ttlSeconds || ttlDays || 1209600; // Default to 14 days in seconds
var ttl = meta.getSessionTTLSeconds();
if (nconf.get('redis')) {
sessionStore = require('connect-redis')(session);

@ -60,13 +60,9 @@
var meta = require('../meta');
var sessionStore = require('connect-redis')(session);
var ttlDays = 60 * 60 * 24 * (parseInt(meta.config.loginDays, 10) || 0);
var ttlSeconds = (parseInt(meta.config.loginSeconds, 10) || 0);
var ttl = ttlSeconds || ttlDays || 1209600; // Default to 14 days
module.sessionStore = new sessionStore({
client: module.client,
ttl: ttl,
ttl: meta.getSessionTTLSeconds(),
});
if (typeof callback === 'function') {

@ -51,6 +51,13 @@ var utils = require('./utils');
restart();
};
Meta.getSessionTTLSeconds = function () {
var ttlDays = 60 * 60 * 24 * (parseInt(Meta.config.loginDays, 10) || 0);
var ttlSeconds = (parseInt(Meta.config.loginSeconds, 10) || 0);
var ttl = ttlSeconds || ttlDays || 1209600; // Default to 14 days
return ttl;
};
if (nconf.get('isPrimary') === 'true') {
pubsub.on('meta:restart', function (data) {
if (data.hostname !== os.hostname()) {

@ -166,9 +166,7 @@ function setupFavicon(app) {
}
function setupCookie() {
var ttlDays = 1000 * 60 * 60 * 24 * (parseInt(meta.config.loginDays, 10) || 0);
var ttlSeconds = 1000 * (parseInt(meta.config.loginSeconds, 10) || 0);
var ttl = ttlSeconds || ttlDays || 1209600000; // Default to 14 days
var ttl = meta.getSessionTTLSeconds() * 1000;
var cookie = {
maxAge: ttl,

@ -192,6 +192,26 @@ describe('meta', function () {
});
describe('session TTL', function () {
it('should return 14 days in seconds', function (done) {
assert(meta.getSessionTTLSeconds(), 1209600);
done();
});
it('should return 7 days in seconds', function (done) {
meta.config.loginDays = 7;
assert(meta.getSessionTTLSeconds(), 604800);
done();
});
it('should return 2 days in seconds', function (done) {
meta.config.loginSeconds = 172800;
assert(meta.getSessionTTLSeconds(), 172800);
done();
});
});
after(function (done) {
db.emptydb(done);
});

Loading…
Cancel
Save