Commit b2b2b2bb authored by JC Brand's avatar JC Brand

Enable automatic anonymous login.

parent 9dae305c
......@@ -244,6 +244,7 @@
allow_registration: true,
animate: true,
auto_list_rooms: false,
auto_login: false, // Currently only used in connection with anonymous login
auto_reconnect: false,
auto_subscribe: false,
bosh_service_url: undefined, // The BOSH connection manager URL.
......@@ -292,6 +293,13 @@
// BBB
if (this.prebind === true) { this.authentication = PREBIND; }
if (this.authentication === ANONYMOUS) {
if (!this.jid) {
throw("Config Error: you need to provide the server's domain via the " +
"'jid' option when using anonymous authentication.");
}
}
if (settings.visible_toolbar_buttons) {
_.extend(
this.visible_toolbar_buttons,
......@@ -5160,6 +5168,7 @@
'MANUAL': MANUAL,
'ANONYMOUS': ANONYMOUS,
'PREBIND': PREBIND,
'auto_login': converse.auto_login,
'authentication': converse.authentication,
'label_username': __('XMPP Username:'),
'label_password': __('Password:'),
......@@ -5183,10 +5192,6 @@
if (ev && ev.preventDefault) { ev.preventDefault(); }
var $form = $(ev.target);
if (converse.authentication === ANONYMOUS) {
if (!converse.jid) {
throw("Config Error: you need to provide the server's domain via the " +
"'jid' option when using anonymous authentication.");
}
this.connect($form, converse.jid, null);
return;
}
......@@ -5379,6 +5384,8 @@
if (rid && sid && jid) {
this.session.save({rid: rid}); // The RID needs to be increased with each request.
this.connection.attach(jid, sid, rid, this.onConnect);
} else if (this.authentication === ANONYMOUS && this.auto_login) {
this.connection.connect(this.jid, null, this.onConnect);
}
}
} else if (this.authentication == "prebind") {
......
......@@ -52,7 +52,9 @@
<script>
require(['converse'], function (converse) {
converse.initialize({
auto_login: true,
allow_registration: false,
allow_logout: false,
authentication: "anonymous",
jid: "opkode.im",
bosh_service_url: 'https://conversejs.org/http-bind/', // Please use this connection manager only for testing purposes
......
<form id="converse-login" method="post">
{[ if (auto_login) { ]}
<span class="spinner login-submit"/>
{[ } ]}
{[ if (!auto_login) { ]}
{[ if (authentication == MANUAL) { ]}
<label>{{label_username}}</label>
<input type="email" name="jid" placeholder="user@server">
......@@ -13,4 +17,5 @@
{[ if (authentication == PREBIND) { ]}
<p>Disconnected.</p>
{[ } ]}
{[ } ]}
</form>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment