v1.18.x
Julian Lam 8 years ago
parent ff3ca28db8
commit e2b40ddf34

@ -28,9 +28,11 @@ app.isConnected = false;
setTimeout(socket.connect.bind(socket), parseInt(config.reconnectionDelay, 10) * 10); setTimeout(socket.connect.bind(socket), parseInt(config.reconnectionDelay, 10) * 10);
}); });
socket.on('checkSession', function (uid) { socket.on('checkSession', function (uid, remoteExist) {
if (parseInt(uid, 10) !== parseInt(app.user.uid, 10)) { if (parseInt(uid, 10) !== parseInt(app.user.uid, 10) && remoteExist) {
app.handleInvalidSession(); app.handleInvalidSession();
} else {
app.logout();
} }
}); });

@ -75,15 +75,17 @@ function onConnection(socket) {
} }
function onConnect(socket) { function onConnect(socket) {
if (socket.uid) { user.exists(socket.uid, function (err, exists) {
socket.join('uid_' + socket.uid); if (socket.uid) {
socket.join('online_users'); socket.join('uid_' + socket.uid);
} else { socket.join('online_users');
socket.join('online_guests'); } else {
} socket.join('online_guests');
}
socket.join('sess_' + socket.request.signedCookies[nconf.get('sessionKey')]); socket.join('sess_' + socket.request.signedCookies[nconf.get('sessionKey')]);
io.sockets.sockets[socket.id].emit('checkSession', socket.uid); io.sockets.sockets[socket.id].emit('checkSession', socket.uid, exists);
});
} }
function onMessage(socket, payload) { function onMessage(socket, payload) {

Loading…
Cancel
Save