diff --git a/src/client/caseCorrect.js b/src/client/caseCorrect.js index d27f4b9..2eb634a 100644 --- a/src/client/caseCorrect.js +++ b/src/client/caseCorrect.js @@ -3,10 +3,10 @@ var UUID = require('uuid-1345'); module.exports = function(client, options) { var clientToken = options.clientToken || UUID.v4().toString(); - var accessToken; - var haveCredentials = options.password != null || (clientToken != null && options.session != null); + options.accessToken = null; + options.haveCredentials = options.password != null || (clientToken != null && options.session != null); - if(haveCredentials) { + if(options.haveCredentials) { // make a request to get the case-correct username before connecting. var cb = function(err, session) { if(err) { @@ -14,7 +14,7 @@ module.exports = function(client, options) { } else { client.session = session; client.username = session.selectedProfile.name; - accessToken = session.accessToken; + options.accessToken = session.accessToken; client.emit('session'); options.connect(client); } diff --git a/src/client/encrypt.js b/src/client/encrypt.js index c5c4443..696ddfc 100644 --- a/src/client/encrypt.js +++ b/src/client/encrypt.js @@ -16,7 +16,7 @@ module.exports = function(client, options) { client.end(); return; } - if(haveCredentials) { + if(options.haveCredentials) { joinServerRequest(onJoinServerResponse); } else { if(packet.serverId != '-') { @@ -35,7 +35,7 @@ module.exports = function(client, options) { } function joinServerRequest(cb) { - yggserver.join(accessToken, client.session.selectedProfile.id, + yggserver.join(options.accessToken, client.session.selectedProfile.id, packet.serverId, sharedSecret, packet.publicKey, cb); }