Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
Make sessions system to be able to turn off
Browse files Browse the repository at this point in the history
Signed-off-by: Bruno Bottazzini <bruno.bottazzini@intel.com>
  • Loading branch information
Bruno Bottazzini committed Oct 15, 2015
1 parent 71bdbc0 commit 97d873f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 20 deletions.
40 changes: 22 additions & 18 deletions server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
'use strict';

var express = require('express');
var session = require('express-session');
var SessionStore = require('session-file-store')(session);
var path = require('path');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
Expand All @@ -53,22 +51,28 @@
jConf = getConfigurationJson(args[0]);
}

app.use(session({
genid: function(req) {
// uuid for guest session ids
var id = uuid.v4();
console.log("New session: " + id);
return id;
},
name: "dad-session",
secret: 'keepitsecret',
resave: true,
saveUninitialized: true,
store: new SessionStore({
retries: 500,
path: jConf.sessions_dir
})
}));
if (jConf.session_system === true) {
var session = require('express-session');
var SessionStore = require('session-file-store')(session);
app.use(session({
genid: function(req) {
// uuid for guest session ids
var id = uuid.v4();
console.log("New session: " + id);
return id;
},
name: "dad-session",
secret: 'keepitsecret',
resave: true,
saveUninitialized: true,
store: new SessionStore({
retries: 500,
minTimeout: 150,
maxTimeout: 200,
path: jConf.sessions_dir
})
}));
}

// view engine setup
app.set('views', path.join(__dirname, 'views'));
Expand Down
3 changes: 2 additions & 1 deletion server/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
"fbp_service_status_refresh_period": 1000,
"syntax_check_refresh_period": 1100,
"save_file_period": 5000,
"run_dialog_refresh_period": 1000
"run_dialog_refresh_period": 1000,
"sessions_system": false
}
8 changes: 7 additions & 1 deletion server/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
module.exports = function () {
var fs = require('fs');
var path = require('path');
require('./configuration.js')();

this.home_dir = function(user) {
return __dirname + '/../repos/' + user + '/';
Expand All @@ -48,7 +49,12 @@ module.exports = function () {
};

this.current_user = function (req) {
return req.sessionID;
var jConf = getConfigurationJson();
if (jConf.session_system === true) {
return req.sessionID;
} else {
return "singlesession";
}
};

this.processReq = function(_p, res) {
Expand Down

0 comments on commit 97d873f

Please sign in to comment.