Merge pull request #592 from davec82/master

add random resource also for auto_login
This commit is contained in:
JC Brand 2016-02-16 15:52:22 +01:00
commit d66ea2079f
2 changed files with 13 additions and 3 deletions

View File

@ -13,6 +13,7 @@
- #573 xgettext build error: `'javascript' unknown` [jcbrand]
- #587 Fix issue when logging out with `auto_logout=true` [davec82]
- #589 Save scroll position on minimize and restore it on maximize [rlanvin]
- #592 Add random resource for auto_login, add method generateResource to generate random resource [davec82]
## 0.10.1 (2016-02-06)

View File

@ -415,6 +415,10 @@
// Module-level functions
// ----------------------
this.generateResource = function () {
return '/converse.js-' + Math.floor(Math.random()*139749825).toString();
};
this.sendCSI = function (stat) {
/* Send out a Chat Status Notification (XEP-0352) */
if (converse.features[Strophe.NS.CSI] || true) {
@ -4723,9 +4727,9 @@
if (jid) {
resource = Strophe.getResourceFromJid(jid);
if (!resource) {
jid = jid.toLowerCase() + '/converse.js-' + Math.floor(Math.random()*139749825).toString();
jid = jid.toLowerCase() + converse.generateResource();
} else {
jid = Strophe.getBareJidFromJid(jid).toLowerCase()+'/'+Strophe.getResourceFromJid(jid);
jid = Strophe.getBareJidFromJid(jid).toLowerCase()+'/'+resource;
}
}
converse.connection.connect(jid, password, converse.onConnectStatusChanged);
@ -4893,7 +4897,12 @@
throw new Error("initConnection: If you use auto_login and "+
"authentication='login' then you also need to provide a password.");
}
this.jid = Strophe.getBareJidFromJid(this.jid).toLowerCase()+'/'+Strophe.getResourceFromJid(this.jid);
var resource = Strophe.getResourceFromJid(this.jid);
if (!resource) {
this.jid = this.jid.toLowerCase() + converse.generateResource();
} else {
this.jid = Strophe.getBareJidFromJid(this.jid).toLowerCase()+'/'+resource;
}
this.connection.connect(this.jid, this.password, this.onConnectStatusChanged);
}
}