Don't try to restore if rid, jid and sid are passed in.

Fixes an issue whereby those tokens are passed in but not used and instead
converse attempts to restore the session (and then totally ignores the tokens
when it fails).

Makes sense to me that you'd want your passed in tokens to be used always, even
when there are restorable tokens.
This commit is contained in:
JC Brand 2016-03-15 18:09:50 +00:00
parent 57aae4ad26
commit 3fd2225fae

View File

@ -1685,7 +1685,9 @@
this.attemptPreboundSession = function (tokens) { this.attemptPreboundSession = function (tokens) {
/* Handle session resumption or initialization when prebind is being used. /* Handle session resumption or initialization when prebind is being used.
*/ */
if (this.keepalive) { if (this.jid && this.sid && this.rid) {
return this.connection.attach(this.jid, this.sid, this.rid, this.onConnectStatusChanged);
} else if (this.keepalive) {
if (!this.jid) { if (!this.jid) {
throw new Error("initConnection: when using 'keepalive' with 'prebind, you must supply the JID of the current user."); throw new Error("initConnection: when using 'keepalive' with 'prebind, you must supply the JID of the current user.");
} }
@ -1695,14 +1697,10 @@
this.log("Could not restore session for jid: "+this.jid+" Error message: "+e.message); this.log("Could not restore session for jid: "+this.jid+" Error message: "+e.message);
this.clearSession(); // If there's a roster, we want to clear it (see #555) this.clearSession(); // If there's a roster, we want to clear it (see #555)
} }
} else { // Not keepalive
if (this.jid && this.sid && this.rid) {
return this.connection.attach(this.jid, this.sid, this.rid, this.onConnectStatusChanged);
} else { } else {
throw new Error("initConnection: If you use prebind and not keepalive, "+ throw new Error("initConnection: If you use prebind and not keepalive, "+
"then you MUST supply JID, RID and SID values"); "then you MUST supply JID, RID and SID values");
} }
}
// We haven't been able to attach yet. Let's see if there // We haven't been able to attach yet. Let's see if there
// is a prebind_url, otherwise there's nothing with which // is a prebind_url, otherwise there's nothing with which
// we can attach. // we can attach.