1
1
var express = require ( 'express' ) ,
2
+ session = require ( 'express-session' ) ,
2
3
tty = require ( 'tty.js' ) ,
3
4
app = express ( ) ,
4
5
util = require ( 'util' ) ,
@@ -22,7 +23,7 @@ var express = require('express'),
22
23
exec_helper = require ( './helpers/exec_helper' ) ,
23
24
request_helper = require ( './helpers/request_helper' ) ,
24
25
debug_helper = require ( './helpers/python/debug_helper' ) ,
25
- RedisStore = require ( 'connect-redis' ) ( express ) ,
26
+ RedisStore = require ( 'connect-redis' ) ( session ) ,
26
27
redis = require ( "redis" ) ,
27
28
client = redis . createClient ( ) ,
28
29
config = require ( './config/config' ) ,
@@ -39,7 +40,7 @@ winston.info("REPOSITORY_PATH", REPOSITORY_PATH);
39
40
40
41
//check for the existence of the logs directory, if it doesn't
41
42
//exist, create it prior to starting the child process.
42
- var exists = path . existsSync ( __dirname + '/logs' ) ;
43
+ var exists = fs . existsSync ( __dirname + '/logs' ) ;
43
44
if ( ! exists ) {
44
45
fs . mkdirSync ( __dirname + '/logs' , 0755 ) ;
45
46
winston . info ( 'created logs folder' ) ;
@@ -138,10 +139,12 @@ app.use(express.logger());
138
139
app . use ( express . static ( __dirname + '/public' ) ) ;
139
140
app . use ( express . static ( __dirname + '/node_modules/tty.js/static' ) ) ;
140
141
app . use ( express . cookieParser ( ) ) ;
141
- app . use ( express . session ( {
142
+ app . use ( session ( {
142
143
store : sessionStore ,
143
144
key : 'sid' ,
144
- secret : 'cat nap'
145
+ secret : 'cat nap' ,
146
+ resave : true ,
147
+ saveUninitialized : true
145
148
} ) ) ;
146
149
app . use ( express . bodyParser ( ) ) ;
147
150
app . use ( express . methodOverride ( ) ) ;
@@ -321,18 +324,18 @@ function setHostName(req) {
321
324
function serverInitialization ( app ) {
322
325
323
326
//setup repositories path
324
- var exists = path . existsSync ( REPOSITORY_PATH ) ;
327
+ var exists = fs . existsSync ( REPOSITORY_PATH ) ;
325
328
if ( ! exists ) {
326
329
fs . mkdirSync ( REPOSITORY_PATH , 0777 ) ;
327
330
winston . info ( 'created repositories folder' ) ;
328
331
}
329
332
330
333
//setup symlink to webide home, if it exists:
331
- var has_webide_path = path . existsSync ( "/home/webide" ) ;
334
+ var has_webide_path = fs . existsSync ( "/home/webide" ) ;
332
335
if ( has_webide_path ) {
333
336
//Creating symbolic link to repositories path
334
337
winston . info ( 'Linked repository paths: /home/webide/repositories' ) ;
335
- if ( ! path . existsSync ( "/home/webide/repositories" ) ) {
338
+ if ( ! fs . existsSync ( "/home/webide/repositories" ) ) {
336
339
fs . symlinkSync ( REPOSITORY_PATH , "/home/webide/repositories" , 'dir' ) ;
337
340
}
338
341
}
@@ -381,7 +384,7 @@ function start_server(cb) {
381
384
function socket_listeners ( ) {
382
385
io . sockets . authorization ( function ( handshakeData , callback ) {
383
386
if ( ! handshakeData . headers . cookie ) return callback ( 'socket.io: cookie not found.' , false ) ;
384
- var signedCookies = require ( 'express/node_modules/ cookie' ) . parse ( handshakeData . headers . cookie ) ;
387
+ var signedCookies = require ( 'cookie' ) . parse ( handshakeData . headers . cookie ) ;
385
388
handshakeData . cookies = require ( 'connect/lib/utils' ) . parseSignedCookies ( signedCookies , 'cat nap' ) ;
386
389
387
390
sessionStore . get ( handshakeData . cookies [ 'sid' ] , function ( err , session ) {
0 commit comments