diff --git a/lib/client/konsole.js b/lib/client/konsole.js index d74c45fa..c50c7270 100644 --- a/lib/client/konsole.js +++ b/lib/client/konsole.js @@ -16,6 +16,7 @@ Loaded, Images = DOM.Images, Dialog = DOM.Dialog, + exec = Util.exec, Konsole = this; @@ -51,19 +52,7 @@ var prefix = getPrefix(); Console(Element, prefix, function(spawn) { - DOM.Files.get('config', function(error, config) { - if (error) - return Dialog.alert(TITLE, error); - - if (config.auth) { - spawn.emit('auth', config.username, config.password); - - spawn.on('auth', function() { - Dialog.alert(TITLE, 'Wrong credentials!'); - }); - } - }); - + spawn.on('connect', exec.with(authCheck, spawn)); Util.exec(callback); }); @@ -78,6 +67,21 @@ }); } + function authCheck(spawn) { + DOM.Files.get('config', function(error, config) { + if (error) + return Dialog.alert(TITLE, error); + + if (config.auth) { + spawn.emit('auth', config.username, config.password); + + spawn.on('auth', function() { + Dialog.alert(TITLE, 'Wrong credentials!'); + }); + } + }); + } + this.show = function(callback) { if (Loaded) CloudCmd.View.show(Element, {