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).
This commit is contained in:
JC Brand 2016-08-23 18:10:08 +00:00
parent f5b182c365
commit 3c9b5bd7a0
2 changed files with 15 additions and 5 deletions

View File

@ -64,7 +64,13 @@
}, },
afterReconnected: function () { 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 () { _tearDown: function () {

View File

@ -409,8 +409,7 @@
converse.connection.reset(); converse.connection.reset();
converse.log('The connection has dropped, attempting to reconnect.'); converse.log('The connection has dropped, attempting to reconnect.');
converse.giveFeedback( converse.giveFeedback(
__("Reconnecting"), 'warn', __("Reconnecting"), 'warn', __('The connection has dropped, attempting to reconnect.')
__('The connection has dropped, attempting to reconnect.')
); );
converse.clearSession(); converse.clearSession();
converse._tearDown(); converse._tearDown();
@ -1764,8 +1763,13 @@
} else if (this.authentication === converse.LOGIN) { } else if (this.authentication === converse.LOGIN) {
var password = converse.connection.pass || this.password; var password = converse.connection.pass || this.password;
if (!password) { if (!password) {
throw new Error("initConnection: If you use auto_login and "+ if (this.auto_login && !this.password) {
"authentication='login' then you also need to provide a 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); var resource = Strophe.getResourceFromJid(this.jid);
if (!resource) { if (!resource) {