Pass haveCredentials/accessToken between client/caseCorrect and client/encrypt

This commit is contained in:
deathcap 2016-01-26 00:51:44 -08:00
parent 2f60088fdf
commit bf5ce9e569
2 changed files with 6 additions and 6 deletions

View File

@ -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);
}

View File

@ -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);
}