From aeaa70ca0c3f64c101bcc134500295627a3ca273 Mon Sep 17 00:00:00 2001 From: Damian Minkov Date: Tue, 5 Aug 2014 12:13:21 +0300 Subject: [PATCH] Handles two domains one for anonymous users, and one for authorized one, where only authorized users can create chat rooms. --- app.js | 2 +- config.js | 1 + muc.js | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index 0ac25d0a7..843c8c65e 100644 --- a/app.js +++ b/app.js @@ -66,7 +66,7 @@ function init() { return; } - var jid = document.getElementById('jid').value || config.hosts.domain || window.location.hostname; + var jid = document.getElementById('jid').value || config.hosts.anonymousdomain || config.hosts.domain || window.location.hostname; connect(jid); } diff --git a/config.js b/config.js index f0fef9c2f..293d97a1e 100644 --- a/config.js +++ b/config.js @@ -1,6 +1,7 @@ var config = { hosts: { domain: 'jitsi-meet.example.com', + //anonymousdomain: 'guest.example.com', muc: 'conference.jitsi-meet.example.com', // FIXME: use XEP-0030 bridge: 'jitsi-videobridge.jitsi-meet.example.com', // FIXME: use XEP-0030 //call_control: 'callcontrol.jitsi-meet.example.com' diff --git a/muc.js b/muc.js index af3280b4c..9ef44de53 100644 --- a/muc.js +++ b/muc.js @@ -157,6 +157,17 @@ Strophe.addConnectionPlugin('emuc', { var from = pres.getAttribute('from'); if ($(pres).find('>error[type="auth"]>not-authorized[xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]').length) { $(document).trigger('passwordrequired.muc', [from]); + } else if ($(pres).find( + '>error[type="cancel"]>not-allowed[xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]').length) { + var toDomain = Strophe.getDomainFromJid(pres.getAttribute('to')); + if(toDomain === config.hosts.anonymousdomain) { + // we are connected with anonymous domain and only non anonymous users can create rooms + // we must authorize the user + $(document).trigger('passwordrequired.main'); + } + else + console.warn('onPresError ', pres); + } else { console.warn('onPresError ', pres); }