mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-16 18:56:15 +01:00
closes #4989
This commit is contained in:
3
app.js
3
app.js
@@ -117,6 +117,9 @@ function start() {
|
|||||||
if (!nconf.get('upload_path')) {
|
if (!nconf.get('upload_path')) {
|
||||||
nconf.set('upload_path', '/public/uploads');
|
nconf.set('upload_path', '/public/uploads');
|
||||||
}
|
}
|
||||||
|
if (!nconf.get('sessionKey')) {
|
||||||
|
nconf.set('sessionKey', 'express.sid');
|
||||||
|
}
|
||||||
// Parse out the relative_url and other goodies from the configured URL
|
// Parse out the relative_url and other goodies from the configured URL
|
||||||
var urlObject = url.parse(nconf.get('url'));
|
var urlObject = url.parse(nconf.get('url'));
|
||||||
var relativePath = urlObject.pathname !== '/' ? urlObject.pathname : '';
|
var relativePath = urlObject.pathname !== '/' ? urlObject.pathname : '';
|
||||||
|
|||||||
@@ -133,10 +133,10 @@ var ratelimit = require('../middleware/ratelimit');
|
|||||||
|
|
||||||
function validateSession(socket, callback) {
|
function validateSession(socket, callback) {
|
||||||
var req = socket.request;
|
var req = socket.request;
|
||||||
if (!req.signedCookies || !req.signedCookies['express.sid']) {
|
if (!req.signedCookies || !req.signedCookies[nconf.get('sessionKey')]) {
|
||||||
return callback(new Error('[[error:invalid-session]]'));
|
return callback(new Error('[[error:invalid-session]]'));
|
||||||
}
|
}
|
||||||
db.sessionStore.get(req.signedCookies['express.sid'], function (err, sessionData) {
|
db.sessionStore.get(req.signedCookies[nconf.get('sessionKey')], function (err, sessionData) {
|
||||||
if (err || !sessionData) {
|
if (err || !sessionData) {
|
||||||
return callback(err || new Error('[[error:invalid-session]]'));
|
return callback(err || new Error('[[error:invalid-session]]'));
|
||||||
}
|
}
|
||||||
@@ -157,7 +157,7 @@ var ratelimit = require('../middleware/ratelimit');
|
|||||||
cookieParser(request, {}, next);
|
cookieParser(request, {}, next);
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
db.sessionStore.get(request.signedCookies['express.sid'], function (err, sessionData) {
|
db.sessionStore.get(request.signedCookies[nconf.get('sessionKey')], function (err, sessionData) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ function setupExpressApp(app) {
|
|||||||
app.use(session({
|
app.use(session({
|
||||||
store: db.sessionStore,
|
store: db.sessionStore,
|
||||||
secret: nconf.get('secret'),
|
secret: nconf.get('secret'),
|
||||||
key: 'express.sid',
|
key: nconf.get('sessionKey'),
|
||||||
cookie: setupCookie(),
|
cookie: setupCookie(),
|
||||||
resave: true,
|
resave: true,
|
||||||
saveUninitialized: true
|
saveUninitialized: true
|
||||||
|
|||||||
Reference in New Issue
Block a user