Commit e0d1a32f authored by JC Brand's avatar JC Brand

Attempt to reconnect when authfail happens

and auto_login is true and credentials_url is set.

Trying to handle the case where tokens are used for credentials_url (and the
token is expired).

Not yet 100% happy with this implementation.
parent 6b3fbc99
......@@ -48,6 +48,13 @@
}
},
onDisconnected: function () {
if (!converse.auto_reconnect) {
converse.renderLoginPanel();
}
return this._super.onDisconnected.apply(this, arguments);
},
_tearDown: function () {
this._super._tearDown.apply(this, arguments);
if (this.rosterview) {
......
......@@ -448,6 +448,20 @@
}.bind(this), 5000);
};
this.onDisconnected = function (condition) {
if (!converse.auto_reconnect) { return; }
if ( converse.disconnection_cause === Strophe.Status.CONNFAIL ||
( converse.disconnection_cause === Strophe.Status.AUTHFAIL &&
converse.credentials_url &&
converse.auto_login
)
) {
converse.reconnect(condition);
} else {
converse.giveFeedback(__('Disconnected'), 'error');
}
};
this.onConnectStatusChanged = function (status, condition, reconnect) {
converse.log("Status changed to: "+PRETTY_CONNECTION_STATUS[status]);
if (status === Strophe.Status.CONNECTED || status === Strophe.Status.ATTACHED) {
......@@ -470,12 +484,7 @@
converse.onConnected();
}
} else if (status === Strophe.Status.DISCONNECTED) {
if (converse.disconnection_cause === Strophe.Status.CONNFAIL && converse.auto_reconnect) {
converse.reconnect(condition);
} else {
// FIXME: leaky abstraction from converse-controlbox.js
converse.renderLoginPanel();
}
converse.onDisconnected(condition);
} else if (status === Strophe.Status.ERROR) {
converse.giveFeedback(__('Error'), 'error');
} else if (status === Strophe.Status.CONNECTING) {
......@@ -489,9 +498,9 @@
} else if (status === Strophe.Status.CONNFAIL) {
converse.disconnection_cause = Strophe.Status.CONNFAIL;
} else if (status === Strophe.Status.DISCONNECTING) {
// FIXME: what about prebind?
if (!converse.connection.connected) {
// FIXME: leaky abstraction from converse-controlbox.js
// Is this needed at all?
converse.renderLoginPanel();
}
if (condition) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment