From 3c9b5bd7a003222658379122374e6ce0009c2881 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Tue, 23 Aug 2016 18:10:08 +0000 Subject: [PATCH] More work on session management. When it's not possible to reconnect due to password no longer being cached, render the login form. Fixed a bug whereby after one failed reconnection event, reconnection becomes impossible (due to 'connection' state of the controlbox). --- src/converse-controlbox.js | 8 +++++++- src/converse-core.js | 12 ++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/converse-controlbox.js b/src/converse-controlbox.js index acc37ddfa..ffe81b474 100644 --- a/src/converse-controlbox.js +++ b/src/converse-controlbox.js @@ -64,7 +64,13 @@ }, afterReconnected: function () { - view.model.set({connected:true}); + this._super.afterReconnected.apply(this, arguments); + var view = converse.chatboxviews.get('controlbox'); + if (view.model.get('connected')) { + converse.chatboxviews.get("controlbox").onConnected(); + } else { + view.model.set({connected:true}); + } }, _tearDown: function () { diff --git a/src/converse-core.js b/src/converse-core.js index b6c7370ca..7e44eed05 100755 --- a/src/converse-core.js +++ b/src/converse-core.js @@ -409,8 +409,7 @@ converse.connection.reset(); converse.log('The connection has dropped, attempting to reconnect.'); converse.giveFeedback( - __("Reconnecting"), 'warn', - __('The connection has dropped, attempting to reconnect.') + __("Reconnecting"), 'warn', __('The connection has dropped, attempting to reconnect.') ); converse.clearSession(); converse._tearDown(); @@ -1764,8 +1763,13 @@ } else if (this.authentication === converse.LOGIN) { var password = converse.connection.pass || this.password; if (!password) { - throw new Error("initConnection: If you use auto_login and "+ - "authentication='login' then you also need to provide a password."); + if (this.auto_login && !this.password) { + throw new Error("initConnection: If you use auto_login and "+ + "authentication='login' then you also need to provide a password."); + } + converse.disconnection_cause = Strophe.Status.AUTHFAIL; + converse.onDisconnected(); + converse.giveFeedback(''); // Wipe the feedback } var resource = Strophe.getResourceFromJid(this.jid); if (!resource) {