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,
|
allow_registration: true,
|
||||||
animate: true,
|
animate: true,
|
||||||
auto_list_rooms: false,
|
auto_list_rooms: false,
|
||||||
|
auto_login: false, // Currently only used in connection with anonymous login
|
||||||
auto_reconnect: false,
|
auto_reconnect: false,
|
||||||
auto_subscribe: false,
|
auto_subscribe: false,
|
||||||
bosh_service_url: undefined, // The BOSH connection manager URL.
|
bosh_service_url: undefined, // The BOSH connection manager URL.
|
||||||
@ -292,6 +293,13 @@
|
|||||||
// BBB
|
// BBB
|
||||||
if (this.prebind === true) { this.authentication = PREBIND; }
|
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) {
|
if (settings.visible_toolbar_buttons) {
|
||||||
_.extend(
|
_.extend(
|
||||||
this.visible_toolbar_buttons,
|
this.visible_toolbar_buttons,
|
||||||
@ -5160,6 +5168,7 @@
|
|||||||
'MANUAL': MANUAL,
|
'MANUAL': MANUAL,
|
||||||
'ANONYMOUS': ANONYMOUS,
|
'ANONYMOUS': ANONYMOUS,
|
||||||
'PREBIND': PREBIND,
|
'PREBIND': PREBIND,
|
||||||
|
'auto_login': converse.auto_login,
|
||||||
'authentication': converse.authentication,
|
'authentication': converse.authentication,
|
||||||
'label_username': __('XMPP Username:'),
|
'label_username': __('XMPP Username:'),
|
||||||
'label_password': __('Password:'),
|
'label_password': __('Password:'),
|
||||||
@ -5183,10 +5192,6 @@
|
|||||||
if (ev && ev.preventDefault) { ev.preventDefault(); }
|
if (ev && ev.preventDefault) { ev.preventDefault(); }
|
||||||
var $form = $(ev.target);
|
var $form = $(ev.target);
|
||||||
if (converse.authentication === ANONYMOUS) {
|
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);
|
this.connect($form, converse.jid, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -5379,6 +5384,8 @@
|
|||||||
if (rid && sid && jid) {
|
if (rid && sid && jid) {
|
||||||
this.session.save({rid: rid}); // The RID needs to be increased with each request.
|
this.session.save({rid: rid}); // The RID needs to be increased with each request.
|
||||||
this.connection.attach(jid, sid, rid, this.onConnect);
|
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") {
|
} else if (this.authentication == "prebind") {
|
||||||
|
2
dev.html
2
dev.html
@ -52,7 +52,9 @@
|
|||||||
<script>
|
<script>
|
||||||
require(['converse'], function (converse) {
|
require(['converse'], function (converse) {
|
||||||
converse.initialize({
|
converse.initialize({
|
||||||
|
auto_login: true,
|
||||||
allow_registration: false,
|
allow_registration: false,
|
||||||
|
allow_logout: false,
|
||||||
authentication: "anonymous",
|
authentication: "anonymous",
|
||||||
jid: "opkode.im",
|
jid: "opkode.im",
|
||||||
bosh_service_url: 'https://conversejs.org/http-bind/', // Please use this connection manager only for testing purposes
|
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">
|
<form id="converse-login" method="post">
|
||||||
{[ if (authentication == MANUAL) { ]}
|
{[ if (auto_login) { ]}
|
||||||
<label>{{label_username}}</label>
|
<span class="spinner login-submit"/>
|
||||||
<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) { ]}
|
{[ if (!auto_login) { ]}
|
||||||
<input type="submit" class="submit login-anon" value="{{label_anon_login}}"/>
|
{[ if (authentication == MANUAL) { ]}
|
||||||
{[ } ]}
|
<label>{{label_username}}</label>
|
||||||
{[ if (authentication == PREBIND) { ]}
|
<input type="email" name="jid" placeholder="user@server">
|
||||||
<p>Disconnected.</p>
|
<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>
|
</form>
|
||||||
|
Loading…
Reference in New Issue
Block a user