From 0e0d1e2973b5b9747e8022986eedb650394b6714 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 14 Oct 2015 13:22:45 -0400 Subject: [PATCH] fix(console) authCheck called once --- lib/client/konsole.js | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) 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, {