Wrong password test with failure callback

This commit is contained in:
David Cormier 2013-10-27 11:01:28 -04:00
parent d6ceadb1be
commit 335ec46fc6

View file

@ -234,10 +234,6 @@ weechat.factory('connection', ['$q', '$rootScope', '$log', '$store', 'handlers',
compression: 'off' compression: 'off'
})); }));
// password is bad until the next message
// received proven the otherwise.
$rootScope.passwordError = true;
// We are asking for the weechat version here // We are asking for the weechat version here
// to avoid two problems : // to avoid two problems :
// - If the version is below 0.4.2, we will have a bug // - If the version is below 0.4.2, we will have a bug
@ -249,13 +245,16 @@ weechat.factory('connection', ['$q', '$rootScope', '$log', '$store', 'handlers',
})).then(function(message) { })).then(function(message) {
// If we have received this message // If we have received this message
// that means the user password is good. // that means the user password is good.
$rootScope.passwordError = false;
// Parse the version info message to retrieve // Parse the version info message to retrieve
// the current weechat version. // the current weechat version.
var version = message['objects'][0]['content']['value']; var version = message['objects'][0]['content']['value'];
$rootScope.version = version; $rootScope.version = version;
$log.info(version); $log.info(version);
}, function(error) {
// If the first command fails, it means that we do not have the
// proper password
$rootScope.passwordError = true;
}).then(function() { }).then(function() {
doSendWithCallback(weeChat.Protocol.formatHdata({ doSendWithCallback(weeChat.Protocol.formatHdata({
path: 'buffer:gui_buffers(*)', path: 'buffer:gui_buffers(*)',
@ -320,9 +319,6 @@ weechat.factory('connection', ['$q', '$rootScope', '$log', '$store', 'handlers',
$log.info("Disconnected from relay"); $log.info("Disconnected from relay");
$rootScope.connected = false; $rootScope.connected = false;
failCallbacks('disconnection'); failCallbacks('disconnection');
if ($rootScope.passwordError == true) {
$log.info("wrong password");
}
$rootScope.$apply(); $rootScope.$apply();
} }
@ -342,7 +338,6 @@ weechat.factory('connection', ['$q', '$rootScope', '$log', '$store', 'handlers',
websocket.onerror = function (evt) { websocket.onerror = function (evt) {
// on error it means the connection problem // on error it means the connection problem
// come from the relay not from the password. // come from the relay not from the password.
$rootScope.passwordError = false;
if (evt.type == "error" && websocket.readyState != 1) { if (evt.type == "error" && websocket.readyState != 1) {
failCallbacks('error'); failCallbacks('error');