From 54a33c260c333116abb7482f5275f392254582c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20F=2E=20Romaniello?= Date: Tue, 14 Jan 2014 17:44:03 -0300 Subject: [PATCH] change user to decoded_token --- example/server.js | 1 + lib/index.js | 17 ++--------------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/example/server.js b/example/server.js index 9a694d0..fd3886e 100644 --- a/example/server.js +++ b/example/server.js @@ -38,6 +38,7 @@ sio.set('authorization', socketio_jwt.authorize({ sio.sockets .on('connection', function (socket) { + console.log(socket.handshake.decoded_token.email, 'connected'); socket.on('ping', function (m) { socket.emit('pong', m); }); diff --git a/lib/index.js b/lib/index.js index 52f52cd..2a7c425 100644 --- a/lib/index.js +++ b/lib/index.js @@ -17,7 +17,7 @@ function noQsMethod(options) { return socket.disconnect('unauthorized'); } - socket.user = decoded; + socket.decoded_token = decoded; socket.emit('authenticated'); server.$emit('authenticated', socket); }); @@ -80,24 +80,11 @@ function authorize(options, onConnection) { return auth.fail(error, data, accept); } - data.user = decoded; - data.logged_in = true; + data.decoded_token = decoded; auth.success(data, accept); }); }; } -function filterSocketsByUser(socketIo, filter){ - var handshaken = socketIo.sockets.manager.handshaken; - return Object.keys(handshaken || {}) - .filter(function(skey){ - return filter(handshaken[skey].user); - }) - .map(function(skey){ - return socketIo.sockets.manager.sockets.sockets[skey]; - }); -} - exports.authorize = authorize; -exports.filterSocketsByUser = filterSocketsByUser;