mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-28 05:35:56 -04:00
Pass haveCredentials/accessToken between client/caseCorrect and client/encrypt
This commit is contained in:
parent
2f60088fdf
commit
bf5ce9e569
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user