From bf5ce9e56937b53f0a9e6a9b03a51c8552d066f1 Mon Sep 17 00:00:00 2001 From: deathcap Date: Tue, 26 Jan 2016 00:51:44 -0800 Subject: [PATCH] Pass haveCredentials/accessToken between client/caseCorrect and client/encrypt --- src/client/caseCorrect.js | 8 ++++---- src/client/encrypt.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) 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); }