Handles two domains one for anonymous users, and one for authorized one, where only authorized users can create chat rooms.

This commit is contained in:
Damian Minkov 2014-08-05 12:13:21 +03:00
parent f4ab48092a
commit aeaa70ca0c
3 changed files with 13 additions and 1 deletions

2
app.js
View File

@ -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);
}

View File

@ -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'

11
muc.js
View File

@ -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);
}