From ce06e7d2d61ec977c5f16be769c6c2d1dcf3a5d6 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Thu, 18 Sep 2014 09:29:31 +0200 Subject: [PATCH 1/3] Initial attempt to sort out session issues. --- converse.js | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/converse.js b/converse.js index 566cbacce..1d193b43d 100644 --- a/converse.js +++ b/converse.js @@ -219,7 +219,7 @@ this.forward_messages = false; this.hide_muc_server = false; this.i18n = locales.en; - this.keepalive = true; + this.keepalive = false; this.message_carbons = false; this.no_trimming = false; // Set to true for phantomjs tests (where browser apparently has no width) this.play_sounds = false; @@ -454,13 +454,9 @@ }; this.showLoginForm = function () { + converse._tearDown(); var view = converse.chatboxviews.get('controlbox'); view.model.set({connected:false}); - if (typeof view.loginpanel !== 'undefined' && view.loginpanel.$el.is(':visible')) { - view.loginpanel.showLoginButton(); - } else { - view.render(); - } }; this.onConnect = function (status, condition, reconnect) { @@ -4532,14 +4528,16 @@ }; this._tearDown = function () { - this.features.off().remove(); - this.otr.destroy(); - this.chatboxes.off().remove(); - this.chatboxviews.off().remove(); - this.controlboxtoggle.off().remove(); - this.minimized_chats.off().remove(); - delete this.chatboxes; - delete this.features; + /* Remove those views which are only allowed with a valid + * connection. + */ + if (this.features) { + this.features.off().remove(); + } + if (this.minimized_chats) { + this.minimized_chats.off().remove(); + } + return this; }; this._initialize = function () { @@ -4549,6 +4547,7 @@ this.otr = new this.OTR(); this.initSession(); this.initConnection(); + return this; }; // Initialization From 785919a019d394ee66e36fb69e0b4296a84ed61d Mon Sep 17 00:00:00 2001 From: JC Brand Date: Thu, 18 Sep 2014 18:49:37 +0200 Subject: [PATCH 2/3] Make login method post. Avoids username and pw inadvertently being added to the URL if the submit event handler for some reason fails (which shouldn't happen of course). --- src/templates/login_panel.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/templates/login_panel.html b/src/templates/login_panel.html index 067bfdb47..8a2d51fb6 100644 --- a/src/templates/login_panel.html +++ b/src/templates/login_panel.html @@ -1,4 +1,4 @@ -
+ From 041d5aca5119d081e471a142a374c80c32e790cd Mon Sep 17 00:00:00 2001 From: JC Brand Date: Thu, 18 Sep 2014 18:51:23 +0200 Subject: [PATCH 3/3] Fix issues with rendering login form after session crash. --- converse.js | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/converse.js b/converse.js index 1d193b43d..fb9a96452 100644 --- a/converse.js +++ b/converse.js @@ -430,7 +430,7 @@ }); } if (errback) { - errback(iq); + errback(jid, iq); } } ); @@ -453,10 +453,11 @@ } }; - this.showLoginForm = function () { + this.renderLoginPanel = function () { converse._tearDown(); var view = converse.chatboxviews.get('controlbox'); view.model.set({connected:false}); + view.renderLoginPanel(); }; this.onConnect = function (status, condition, reconnect) { @@ -475,22 +476,25 @@ if (converse.auto_reconnect) { converse.reconnect(); } else { - converse.showLoginForm(); + converse.renderLoginPanel(); } } else if (status === Strophe.Status.Error) { - converse.showLoginForm(); + converse.renderLoginPanel(); converse.giveFeedback(__('Error'), 'error'); } else if (status === Strophe.Status.CONNECTING) { converse.giveFeedback(__('Connecting')); } else if (status === Strophe.Status.CONNFAIL) { - converse.showLoginForm(); + converse.renderLoginPanel(); converse.giveFeedback(__('Connection Failed'), 'error'); } else if (status === Strophe.Status.AUTHENTICATING) { converse.giveFeedback(__('Authenticating')); } else if (status === Strophe.Status.AUTHFAIL) { - converse.showLoginForm(); + converse.renderLoginPanel(); converse.giveFeedback(__('Authentication Failed'), 'error'); } else if (status === Strophe.Status.DISCONNECTING) { + if (!converse.connection.connected) { + converse.renderLoginPanel(); + } converse.giveFeedback(__('Disconnecting'), 'error'); } }; @@ -1913,8 +1917,8 @@ initialize: function () { this.$el.insertAfter(converse.controlboxtoggle.$el); this.model.on('change:connected', $.proxy(function (item) { - this.render(); if (this.model.get('connected')) { + this.render(); this.initRoster(); converse.features.off('add', this.featureAdded, this); converse.features.on('add', this.featureAdded, this); @@ -1959,7 +1963,12 @@ renderLoginPanel: function () { this.$el.html(converse.templates.controlbox(this.model.toJSON())); - this.loginpanel = new converse.LoginPanel({'$parent': this.$el.find('.controlbox-panes'), 'model': this}); + var cfg = {'$parent': this.$el.find('.controlbox-panes'), 'model': this}; + if (!this.loginpanel) { + this.loginpanel = new converse.LoginPanel(cfg); + } else { + this.loginpanel.delegateEvents().initialize(cfg); + } this.loginpanel.render(); this.initDragResize(); }, @@ -3534,15 +3543,15 @@ vcard_updated: moment().format() }); }, this), - $.proxy(function (jid, fullname, img, img_type, url) { + $.proxy(function (jid, iq) { converse.log("Error while retrieving vcard"); - // XXX: Should vcard_updated be set here as well? this.add({ jid: bare_jid, subscription: 'none', ask: null, requesting: true, - fullname: jid + fullname: bare_jid, + vcard_updated: moment().format() }); }, this) );