Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #812 from mleanos/bug/socket-session-key
Browse files Browse the repository at this point in the history
Fixed bug with Socket IO session
  • Loading branch information
lirantal committed Aug 17, 2015
2 parents 1f0f1b7 + 792488e commit 5b78706
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion config/lib/socket.io.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,15 @@ module.exports = function (app, db) {
// Use the 'cookie-parser' module to parse the request cookies
cookieParser(config.sessionSecret)(socket.request, {}, function (err) {
// Get the session id from the request cookies
var sessionId = socket.request.signedCookies['connect.sid'];
var sessionId = socket.request.signedCookies ? socket.request.signedCookies[config.sessionKey] : undefined;

if (!sessionId) return next(new Error('sessionId was not found in socket.request'), false);

// Use the mongoStorage instance to get the Express session information
mongoStore.get(sessionId, function (err, session) {
if (err) return next(err, false);
if (!session) return next(new Error('session was not found for ' + sessionId), false);

// Set the Socket.io session information
socket.request.session = session;

Expand Down

0 comments on commit 5b78706

Please sign in to comment.