diff --git a/example/socketsio-auth0-sample/index.js b/example/socketsio-auth0-sample/index.js index a7c4e83..aba5f43 100644 --- a/example/socketsio-auth0-sample/index.js +++ b/example/socketsio-auth0-sample/index.js @@ -11,6 +11,7 @@ var env = { AUTH0_CLIENT_ID: process.env.AUTH0_CLIENT_ID, AUTH0_DOMAIN: process.env.AUTH0_DOMAIN }; +var port = process.env.PORT || 3001; app.set('views', __dirname + '/views'); app.set('view engine', 'pug'); @@ -34,6 +35,7 @@ app.get('/', function (req, res) { res.render('index', { env: env }); }); -http.listen(3001, function(){ - console.log('listening on *:3001'); +http.listen(port, function(){ + console.log('listening on *:' + port); }); + diff --git a/example/socketsio-auth0-sample/views/index.pug b/example/socketsio-auth0-sample/views/index.pug index 05f5516..774d2f0 100644 --- a/example/socketsio-auth0-sample/views/index.pug +++ b/example/socketsio-auth0-sample/views/index.pug @@ -46,8 +46,12 @@ block content function openChat() { var socket = io(); - socket.on('connect', function () { - socket.on('authenticated', function () { + socket + .on('connect', function (msg) { + console.log("connected"); + socket.emit('authenticate', {token: userToken}); // send the jwt + }) + .on('authenticated', function () { //Do $('#login').hide(); $('#chat').show(); @@ -56,10 +60,13 @@ block content $('#m').val(''); return false; }); - socket.on('chat message', function (msg) { - console.log("msg"); - $('#messages').append($('