Merge branch 'master' into develop

v1.18.x
Julian Lam 8 years ago
commit 48909e753c

@ -22,8 +22,9 @@ require(['translator'], function (shim) {
var translator = shim.Translator.create(); var translator = shim.Translator.create();
var dialog = bootbox.dialog; var dialog = bootbox.dialog;
var attrsToTranslate = ['placeholder', 'title', 'value'];
bootbox.dialog = function (options) { bootbox.dialog = function (options) {
var show, $elem, nodes, text; var show, $elem, nodes, text, attrNodes, attrText;
show = options.show !== false; show = options.show !== false;
options.show = false; options.show = false;
@ -36,10 +37,27 @@ require(['translator'], function (shim) {
return node.nodeValue; return node.nodeValue;
}).join(' || '); }).join(' || ');
translator.translate(text).then(function (translated) { attrNodes = attrsToTranslate.reduce(function (prev, attr) {
return prev.concat(nodes.map.call($elem.find('[' + attr + '*="[["]'), function (el) {
return [attr, el];
}));
}, []);
attrText = attrNodes.map(function (node) {
return node[1].getAttribute(node[0]);
}).join(' || ');
Promise.all([
translator.translate(text),
translator.translate(attrText),
]).then(function (ref) {
var translated = ref[0];
var translatedAttrs = ref[1];
translated.split(' || ').forEach(function (html, i) { translated.split(' || ').forEach(function (html, i) {
$(nodes[i]).replaceWith(html); $(nodes[i]).replaceWith(html);
}); });
translatedAttrs.split(' || ').forEach(function (text, i) {
attrNodes[i][1].setAttribute(attrNodes[i][0], text);
});
if (show) { if (show) {
$elem.modal('show'); $elem.modal('show');
} }

@ -212,7 +212,9 @@ Controllers.registerInterstitial = function (req, res, next) {
} }
if (!data.interstitials.length) { if (!data.interstitials.length) {
return next(); // No interstitials, redirect to home
delete req.session.registration;
return res.redirect('/');
} }
var renders = data.interstitials.map(function (interstitial) { var renders = data.interstitials.map(function (interstitial) {

@ -111,15 +111,23 @@
if (err) { if (err) {
return callback(err); return callback(err);
} }
createSessionStore(); callback();
}); });
} else { } else {
winston.warn('You have no mongo password setup!'); winston.warn('You have no mongo password setup!');
createSessionStore(); callback();
} }
});
};
function createSessionStore() { module.initSessionStore = function (callback) {
var meta = require('../meta');
var sessionStore; var sessionStore;
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
if (nconf.get('redis')) { if (nconf.get('redis')) {
sessionStore = require('connect-redis')(session); sessionStore = require('connect-redis')(session);
var rdb = require('./redis'); var rdb = require('./redis');
@ -127,17 +135,17 @@
module.sessionStore = new sessionStore({ module.sessionStore = new sessionStore({
client: rdb.client, client: rdb.client,
ttl: 60 * 60 * 24 * 14 ttl: ttl
}); });
} else if (nconf.get('mongo')) { } else if (nconf.get('mongo')) {
sessionStore = require('connect-mongo')(session); sessionStore = require('connect-mongo')(session);
module.sessionStore = new sessionStore({ module.sessionStore = new sessionStore({
db: db db: db,
ttl: ttl
}); });
} }
callback(); callback();
}
});
}; };
module.createIndices = function (callback) { module.createIndices = function (callback) {

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

@ -131,7 +131,7 @@ var fallbackTransport;
data.from = data.from_name + '<' + data.from + '>'; data.from = data.from_name + '<' + data.from + '>';
delete data.from_name; delete data.from_name;
winston.verbose('[emailer] Sending email to uid ' + data.uid); winston.verbose('[emailer] Sending email to uid ' + data.uid + ' (' + data.to + ')');
fallbackTransport.sendMail(data, function (err) { fallbackTransport.sendMail(data, function (err) {
if (err) { if (err) {
winston.error(err); winston.error(err);

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

@ -20,7 +20,8 @@
<div class="form-group form-inline"> <div class="form-group form-inline">
<label for="emailConfirmInterval">[[admin/settings/user:email-confirm-interval]]</label> <label for="emailConfirmInterval">[[admin/settings/user:email-confirm-interval]]</label>
<input class="form-control" data-field="emailConfirmInterval" type="number" id="emailConfirmInterval" placeholder="Default: 10" value="10" /> <input class="form-control" data-field="emailConfirmInterval" type="number" id="emailConfirmInterval" placeholder="Default: 10"
value="10" />
<label for="emailConfirmInterval">[[admin/settings/user:email-confirm-email2]]</label> <label for="emailConfirmInterval">[[admin/settings/user:email-confirm-email2]]</label>
</div> </div>
@ -103,10 +104,6 @@
<label for="lockoutDuration">[[admin/settings/user:lockout-duration]]</label> <label for="lockoutDuration">[[admin/settings/user:lockout-duration]]</label>
<input id="lockoutDuration" type="text" class="form-control" data-field="lockoutDuration" placeholder="60" /> <input id="lockoutDuration" type="text" class="form-control" data-field="lockoutDuration" placeholder="60" />
</div> </div>
<div class="form-group">
<label>[[admin/settings/user:login-days]]</label>
<input type="text" class="form-control" data-field="loginDays" placeholder="14" />
</div>
<div class="form-group"> <div class="form-group">
<label>[[admin/settings/user:password-expiry-days]]</label> <label>[[admin/settings/user:password-expiry-days]]</label>
<input type="text" class="form-control" data-field="passwordExpiryDays" placeholder="0" /> <input type="text" class="form-control" data-field="passwordExpiryDays" placeholder="0" />
@ -115,6 +112,24 @@
</div> </div>
</div> </div>
<div class="row">
<div class="col-sm-2 col-xs-12 settings-header">
Session time
</div>
<div class="col-sm-10 col-xs-12">
<form>
<div class="form-group">
<label>Days: </label>
<input type="text" class="form-control" data-field="loginDays" placeholder="Days" />
<label>Seconds: </label>
<input type="text" class="form-control" data-field="loginSeconds" placeholder="Seconds" />
<p class="help-block">Note that only one of these values will be used. If there is no <i>seconds</i> value we fall back to <i>days</i>. If
there is no <i>days</i> value we default to <i>14 days</i>.</p>
</div>
</form>
</div>
</div>
<div class="row"> <div class="row">
<div class="col-sm-2 col-xs-12 settings-header">[[admin/settings/user:registration]]</div> <div class="col-sm-2 col-xs-12 settings-header">[[admin/settings/user:registration]]</div>
<div class="col-sm-10 col-xs-12"> <div class="col-sm-10 col-xs-12">

@ -170,8 +170,12 @@ function setupFavicon(app) {
} }
function setupCookie() { 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 cookie = { var cookie = {
maxAge: 1000 * 60 * 60 * 24 * (parseInt(meta.config.loginDays, 10) || 14) maxAge: ttl
}; };
if (nconf.get('cookieDomain') || meta.config.cookieDomain) { if (nconf.get('cookieDomain') || meta.config.cookieDomain) {

@ -100,6 +100,9 @@
function (next) { function (next) {
meta.configs.init(next); meta.configs.init(next);
}, },
function (next) {
db.initSessionStore(next);
},
function (next) { function (next) {
meta.dependencies.check(next); meta.dependencies.check(next);
}, },

Loading…
Cancel
Save