Skip to content

Commit

Permalink
Fix passport session
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya Radchenko committed Feb 20, 2017
1 parent 7e3fd5c commit 2202e05
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/routes/api/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ router.route('/')
if (!user) {
res.status(404).send({message: 'No such username / password'});
} else {
req.session.user = user.id;
if (!req.session.passport) {
req.session.passport = {};
}
req.session.passport.user = user.id;
res.send(user);
}
});
Expand Down
5 changes: 3 additions & 2 deletions lib/websockets.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ UserSockets.prototype = {
// socket callback. Adds a new socket
connected: function (socket) {
var session = socket.handshake.session;
if (session && session.user) {
this.addSocket(session.user, socket);

if (session && session.passport) {
this.addSocket(session.passport.user, socket);
} else {
console.debug('Websocket connection does not have authorization - nothing to do.');
}
Expand Down

0 comments on commit 2202e05

Please sign in to comment.