mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-11-03 12:36:02 +01:00 
			
		
		
		
	Adding more specific timing for session timings
This commit is contained in:
		@@ -129,11 +129,15 @@
 | 
				
			|||||||
			var rdb = require('./redis');
 | 
								var rdb = require('./redis');
 | 
				
			||||||
			rdb.client = rdb.connect();
 | 
								rdb.client = rdb.connect();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			var ttlDays = 1000 * 60 * 60 * 24 * (parseInt(meta.config.loginDays, 10) || 14);
 | 
								var ttlDays = 1000 * 60 * 60 * 24 * (parseInt(meta.config.loginDays, 10) || 0);
 | 
				
			||||||
 | 
								var ttlHours = 1000 * 60 * 60 * (parseInt(meta.config.loginHours, 10) || 0);
 | 
				
			||||||
 | 
								var ttlMinutes = 1000 * 60 * (parseInt(meta.config.loginMinutes, 10) || 0);
 | 
				
			||||||
 | 
								var ttlSeconds = 1000 * (parseInt(meta.config.loginSeconds, 10) || 0);
 | 
				
			||||||
 | 
								var ttlTotal = (ttlDays + ttlHours + ttlMinutes + ttlSeconds) || 1209600000; // Default to 14 days
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			module.sessionStore = new sessionStore({
 | 
								module.sessionStore = new sessionStore({
 | 
				
			||||||
				client: rdb.client,
 | 
									client: rdb.client,
 | 
				
			||||||
				ttl: ttlDays
 | 
									ttl: ttlTotal
 | 
				
			||||||
			});
 | 
								});
 | 
				
			||||||
		} else if (nconf.get('mongo')) {
 | 
							} else if (nconf.get('mongo')) {
 | 
				
			||||||
			sessionStore = require('connect-mongo')(session);
 | 
								sessionStore = require('connect-mongo')(session);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -60,13 +60,17 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	module.initSessionStore = function (callback) {
 | 
						module.initSessionStore = function (callback) {
 | 
				
			||||||
		var meta = require('../meta');
 | 
							var meta = require('../meta');
 | 
				
			||||||
		connectRedis = require('connect-redis')(session);
 | 
							var sessionStore = require('connect-redis')(session);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		var ttlDays = 1000 * 60 * 60 * 24 * (parseInt(meta.config.loginDays, 10) || 14);
 | 
							var ttlDays = 1000 * 60 * 60 * 24 * (parseInt(meta.config.loginDays, 10) || 0);
 | 
				
			||||||
 | 
							var ttlHours = 1000 * 60 * 60 * (parseInt(meta.config.loginHours, 10) || 0);
 | 
				
			||||||
 | 
							var ttlMinutes = 1000 * 60 * (parseInt(meta.config.loginMinutes, 10) || 0);
 | 
				
			||||||
 | 
							var ttlSeconds = 1000 * (parseInt(meta.config.loginSeconds, 10) || 0);
 | 
				
			||||||
 | 
							var ttlTotal = (ttlDays + ttlHours + ttlMinutes + ttlSeconds) || 1209600000; // Default to 14 days
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		module.sessionStore = new connectRedis({
 | 
							module.sessionStore = new sessionStore({
 | 
				
			||||||
			client: redisClient,
 | 
								client: module.client,
 | 
				
			||||||
			ttl: ttlDays
 | 
								ttl: ttlTotal
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (typeof callback === 'function') {
 | 
							if (typeof callback === 'function') {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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,25 @@
 | 
				
			|||||||
	</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>Hours: </label>
 | 
				
			||||||
 | 
									<input type="text" class="form-control" data-field="loginHours" placeholder="Hours" />
 | 
				
			||||||
 | 
									<label>Minutes: </label>
 | 
				
			||||||
 | 
									<input type="text" class="form-control" data-field="loginMinutes" placeholder="Minutes" />
 | 
				
			||||||
 | 
									<label>Seconds: </label>
 | 
				
			||||||
 | 
									<input type="text" class="form-control" data-field="loginSeconds" placeholder="Seconds" />
 | 
				
			||||||
 | 
								</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">
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -52,7 +52,7 @@ server.on('error', function (err) {
 | 
				
			|||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports.listen = function (callback) {
 | 
					module.exports.listen = function (callback) {
 | 
				
			||||||
	callback = callback || function () {};
 | 
						callback = callback || function () { };
 | 
				
			||||||
	emailer.registerApp(app);
 | 
						emailer.registerApp(app);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	setupExpressApp(app);
 | 
						setupExpressApp(app);
 | 
				
			||||||
@@ -139,7 +139,7 @@ function setupExpressApp(app) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	app.use(relativePath + '/apple-touch-icon', middleware.routeTouchIcon);
 | 
						app.use(relativePath + '/apple-touch-icon', middleware.routeTouchIcon);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	app.use(bodyParser.urlencoded({extended: true}));
 | 
						app.use(bodyParser.urlencoded({ extended: true }));
 | 
				
			||||||
	app.use(bodyParser.json());
 | 
						app.use(bodyParser.json());
 | 
				
			||||||
	app.use(cookieParser());
 | 
						app.use(cookieParser());
 | 
				
			||||||
	app.use(useragent.express());
 | 
						app.use(useragent.express());
 | 
				
			||||||
@@ -170,8 +170,14 @@ function setupFavicon(app) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function setupCookie() {
 | 
					function setupCookie() {
 | 
				
			||||||
 | 
						var ttlDays = 1000 * 60 * 60 * 24 * (parseInt(meta.config.loginDays, 10) || 0);
 | 
				
			||||||
 | 
						var ttlHours = 1000 * 60 * 60 * (parseInt(meta.config.loginHours, 10) || 0);
 | 
				
			||||||
 | 
						var ttlMinutes = 1000 * 60 * (parseInt(meta.config.loginMinutes, 10) || 0);
 | 
				
			||||||
 | 
						var ttlSeconds = 1000 * (parseInt(meta.config.loginSeconds, 10) || 0);
 | 
				
			||||||
 | 
						var ttlTotal = (ttlDays + ttlHours + ttlMinutes + ttlSeconds) || 1209600000; // Default to 14 days
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var cookie = {
 | 
						var cookie = {
 | 
				
			||||||
		maxAge: 1000 * 60 * 60 * 24 * (parseInt(meta.config.loginDays, 10) || 14)
 | 
							maxAge: ttlTotal
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (nconf.get('cookieDomain') || meta.config.cookieDomain) {
 | 
						if (nconf.get('cookieDomain') || meta.config.cookieDomain) {
 | 
				
			||||||
@@ -191,7 +197,7 @@ function setupCookie() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function listen(callback) {
 | 
					function listen(callback) {
 | 
				
			||||||
	callback = callback || function () {};
 | 
						callback = callback || function () { };
 | 
				
			||||||
	var port = parseInt(nconf.get('port'), 10);
 | 
						var port = parseInt(nconf.get('port'), 10);
 | 
				
			||||||
	var isSocket = isNaN(port);
 | 
						var isSocket = isNaN(port);
 | 
				
			||||||
	var socketPath = isSocket ? nconf.get('port') : '';
 | 
						var socketPath = isSocket ? nconf.get('port') : '';
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user