Enable automatic anonymous login.
This commit is contained in:
parent
9dae305c23
commit
b2b2b2bbc0
15
converse.js
15
converse.js
@ -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") {
|
||||
|
2
dev.html
2
dev.html
@ -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
|
||||
|
@ -1,16 +1,21 @@
|
||||
<form id="converse-login" method="post">
|
||||
{[ if (authentication == MANUAL) { ]}
|
||||
<label>{{label_username}}</label>
|
||||
<input type="email" name="jid" placeholder="user@server">
|
||||
<label>{{label_password}}</label>
|
||||
<input type="password" name="password" placeholder="password">
|
||||
<input class="submit" type="submit" value="{{label_login}}">
|
||||
<span class="conn-feedback"></span>
|
||||
{[ if (auto_login) { ]}
|
||||
<span class="spinner login-submit"/>
|
||||
{[ } ]}
|
||||
{[ if (authentication == ANONYMOUS) { ]}
|
||||
<input type="submit" class="submit login-anon" value="{{label_anon_login}}"/>
|
||||
{[ } ]}
|
||||
{[ if (authentication == PREBIND) { ]}
|
||||
<p>Disconnected.</p>
|
||||
{[ if (!auto_login) { ]}
|
||||
{[ if (authentication == MANUAL) { ]}
|
||||
<label>{{label_username}}</label>
|
||||
<input type="email" name="jid" placeholder="user@server">
|
||||
<label>{{label_password}}</label>
|
||||
<input type="password" name="password" placeholder="password">
|
||||
<input class="submit" type="submit" value="{{label_login}}">
|
||||
<span class="conn-feedback"></span>
|
||||
{[ } ]}
|
||||
{[ if (authentication == ANONYMOUS) { ]}
|
||||
<input type="submit" class="submit login-anon" value="{{label_anon_login}}"/>
|
||||
{[ } ]}
|
||||
{[ if (authentication == PREBIND) { ]}
|
||||
<p>Disconnected.</p>
|
||||
{[ } ]}
|
||||
{[ } ]}
|
||||
</form>
|
||||
|
Loading…
Reference in New Issue
Block a user