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 () {
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 () {

View File

@ -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,9 +1763,14 @@
} else if (this.authentication === converse.LOGIN) {
var password = converse.connection.pass || this.password;
if (!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) {
this.jid = this.jid.toLowerCase() + converse.generateResource();