From ca8a147ea652b1435260f9548cc51cedb95c0075 Mon Sep 17 00:00:00 2001 From: paweldomas Date: Wed, 23 Dec 2015 14:57:23 +0100 Subject: [PATCH] JWT token is now passed as BOSH URL parameter. --- modules/UI/UI.js | 12 ++++++++++-- modules/xmpp/strophe.emuc.js | 4 ---- modules/xmpp/xmpp.js | 17 ++++++----------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/modules/UI/UI.js b/modules/UI/UI.js index 9b8ae0ce3..1685f5dfb 100644 --- a/modules/UI/UI.js +++ b/modules/UI/UI.js @@ -325,8 +325,16 @@ function registerListeners() { "dialog.connectError", pres); }); APP.xmpp.addListener(XMPPEvents.ROOM_CONNECT_ERROR, function (pres) { - UI.messageHandler.openReportDialog(null, - "dialog.connectError", pres); + if (config.token && + $(pres).find( + '>error[type="cancel"]' + + '>not-allowed[xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]' + ).length) { + messageHandler.showError("dialog.error", "dialog.tokenAuthFailed"); + } else { + UI.messageHandler.openReportDialog(null, + "dialog.connectError", pres); + } }); APP.xmpp.addListener(XMPPEvents.READY_TO_JOIN, function () { diff --git a/modules/xmpp/strophe.emuc.js b/modules/xmpp/strophe.emuc.js index ef6be3585..2b83c049b 100644 --- a/modules/xmpp/strophe.emuc.js +++ b/modules/xmpp/strophe.emuc.js @@ -562,10 +562,6 @@ module.exports = function(XMPP, eventEmitter) { delete this.presMap["startMuted"]; } - if (config.token) { - pres.c('token', { xmlns: 'http://jitsi.org/jitmeet/auth-token'}).t(config.token).up(); - } - pres.up(); this.connection.send(pres); }, diff --git a/modules/xmpp/xmpp.js b/modules/xmpp/xmpp.js index 0e90713d2..0edc1c41b 100644 --- a/modules/xmpp/xmpp.js +++ b/modules/xmpp/xmpp.js @@ -308,21 +308,16 @@ var XMPP = { configDomain = config.hosts.domain; } var jid = configDomain || window.location.hostname; - var password = null; - if (config.token) { - password = config.token; - if (config.id) { - jid = config.id + "@" + jid; - } else { - jid = generateUserName() + "@" + jid; - } - } - connect(jid, password); + connect(jid); }, createConnection: function () { var bosh = config.bosh || '/http-bind'; // adds the room name used to the bosh connection - return new Strophe.Connection(bosh + '?room=' + APP.UI.getRoomNode()); + bosh += '?room=' + APP.UI.getRoomNode(); + if (config.token) { + bosh += "&token=" + config.token; + } + return new Strophe.Connection(bosh); }, getStatusString: function (status) { return Strophe.getStatusString(status);