From f6a19348ad404aa72c31eef8dc84aac8db0e904a Mon Sep 17 00:00:00 2001 From: Damian Mee Date: Fri, 18 Jul 2014 14:53:09 +0200 Subject: [PATCH] fix(socketio): fallback for servers where `socket.handshake.address` is not provided --- app/templates/server/config/_local.env.js | 19 ++++++++++++------- .../server/config/environment/index.js | 6 +++--- .../server/config/socketio(socketio).js | 6 ++++-- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/app/templates/server/config/_local.env.js b/app/templates/server/config/_local.env.js index 145479041..593c952c5 100644 --- a/app/templates/server/config/_local.env.js +++ b/app/templates/server/config/_local.env.js @@ -6,13 +6,18 @@ // This file should not be tracked by git. module.exports = { - SESSION_SECRET: "<%= _.slugify(appname) + '-secret' %>", - FACEBOOK_ID: "app-id", - FACEBOOK_SECRET: "secret", - TWITTER_ID: "app-id", - TWITTER_SECRET: "secret", - GOOGLE_ID: "app-id", - GOOGLE_SECRET: "secret", + DOMAIN: 'http://localhost:9000', + SESSION_SECRET: "<%= _.slugify(appname) + '-secret' %>", + + FACEBOOK_ID: 'app-id', + FACEBOOK_SECRET: 'secret', + + TWITTER_ID: 'app-id', + TWITTER_SECRET: 'secret', + + GOOGLE_ID: 'app-id', + GOOGLE_SECRET: 'secret', + // Control debug level for modules using visionmedia/debug // DEBUG: "" }; \ No newline at end of file diff --git a/app/templates/server/config/environment/index.js b/app/templates/server/config/environment/index.js index 8eb15c3ce..b6c5ed60a 100644 --- a/app/templates/server/config/environment/index.js +++ b/app/templates/server/config/environment/index.js @@ -44,19 +44,19 @@ var all = { facebook: { clientID: process.env.FACEBOOK_ID || 'id', clientSecret: process.env.FACEBOOK_SECRET || 'secret', - callbackURL: 'http://localhost:9000/auth/facebook/callback' + callbackURL: process.env.DOMAIN + '/auth/facebook/callback' }, <% } %><% if(filters.twitterAuth) { %> twitter: { clientID: process.env.TWITTER_ID || 'id', clientSecret: process.env.TWITTER_SECRET || 'secret', - callbackURL: 'http://localhost:9000/auth/twitter/callback' + callbackURL: process.env.DOMAIN + '/auth/twitter/callback' }, <% } %><% if(filters.googleAuth) { %> google: { clientID: process.env.GOOGLE_ID || 'id', clientSecret: process.env.GOOGLE_SECRET || 'secret', - callbackURL: 'http://localhost:9000/auth/google/callback' + callbackURL: process.env.DOMAIN + '/auth/google/callback' }<% } %> }; diff --git a/app/templates/server/config/socketio(socketio).js b/app/templates/server/config/socketio(socketio).js index dccc709b3..2fbbc07d6 100644 --- a/app/templates/server/config/socketio(socketio).js +++ b/app/templates/server/config/socketio(socketio).js @@ -38,8 +38,10 @@ module.exports = function (socketio) { // })); socketio.on('connection', function (socket) { - socket.address = socket.handshake.address.address + ':' + - socket.handshake.address.port; + socket.address = socket.handshake.address !== null ? + socket.handshake.address.address + ':' + socket.handshake.address.port : + process.env.DOMAIN; + socket.connectedAt = new Date(); // Call onDisconnect.