Implemented auto fetching of registration form for default XMPP domain (#812)
This commit is contained in:
parent
6e94e11dcc
commit
e6f3406977
|
@ -6,6 +6,8 @@
|
||||||
- #628 Fixes the bug in displaying chat status during private chat. [saganshul]
|
- #628 Fixes the bug in displaying chat status during private chat. [saganshul]
|
||||||
- #628 Changes the message displayed while typing from a different resource of the same user. [smitbose]
|
- #628 Changes the message displayed while typing from a different resource of the same user. [smitbose]
|
||||||
- #675 Time format made configurable. [smitbose]
|
- #675 Time format made configurable. [smitbose]
|
||||||
|
- #704 Automatic fetching of registration form when [registration_domain](https://conversejs.org/
|
||||||
|
docs/html/configurations.html#registration-domain) is set. [smitbose]
|
||||||
- #806 The `_converse.listen` API event listeners aren't triggered. [jcbrand]
|
- #806 The `_converse.listen` API event listeners aren't triggered. [jcbrand]
|
||||||
- #807 Error: Plugin "converse-dragresize" tried to override HeadlinesBoxView but it's not found. [jcbrand]
|
- #807 Error: Plugin "converse-dragresize" tried to override HeadlinesBoxView but it's not found. [jcbrand]
|
||||||
- #820 Inconsistency in displaying room features. [jcbrand]
|
- #820 Inconsistency in displaying room features. [jcbrand]
|
||||||
|
|
|
@ -483,6 +483,14 @@ JIDs with other domains are still allowed but need to be provided in full.
|
||||||
To specify only one domain and disallow other domains, see the `locked_domain`_
|
To specify only one domain and disallow other domains, see the `locked_domain`_
|
||||||
option.
|
option.
|
||||||
|
|
||||||
|
registration_domain
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
* Default: ``''``
|
||||||
|
|
||||||
|
Specify a domain name for which the registration form will be fetched automatically,
|
||||||
|
without the user having to enter any XMPP server domain name.
|
||||||
|
|
||||||
default_state
|
default_state
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
|
|
@ -256,6 +256,7 @@
|
||||||
password: undefined,
|
password: undefined,
|
||||||
prebind_url: null,
|
prebind_url: null,
|
||||||
priority: 0,
|
priority: 0,
|
||||||
|
registration_domain: '',
|
||||||
rid: undefined,
|
rid: undefined,
|
||||||
roster_groups: true,
|
roster_groups: true,
|
||||||
show_only_online_users: false,
|
show_only_online_users: false,
|
||||||
|
|
|
@ -72,6 +72,11 @@
|
||||||
'model': this
|
'model': this
|
||||||
});
|
});
|
||||||
this.registerpanel.render().$el.addClass('hidden');
|
this.registerpanel.render().$el.addClass('hidden');
|
||||||
|
|
||||||
|
if (_converse.registration_domain) {
|
||||||
|
this.registerpanel.renderRegistrationRequest('');
|
||||||
|
this.registerpanel.fetchRegistrationForm(_converse.registration_domain);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -116,6 +121,7 @@
|
||||||
render: function () {
|
render: function () {
|
||||||
this.$parent.append(this.$el.html(
|
this.$parent.append(this.$el.html(
|
||||||
tpl_register_panel({
|
tpl_register_panel({
|
||||||
|
'default_domain': _converse.registration_domain,
|
||||||
'label_domain': __("Your XMPP provider's domain name:"),
|
'label_domain': __("Your XMPP provider's domain name:"),
|
||||||
'label_register': __('Fetch registration form'),
|
'label_register': __('Fetch registration form'),
|
||||||
'help_providers': __('Tip: A list of public XMPP providers is available'),
|
'help_providers': __('Tip: A list of public XMPP providers is available'),
|
||||||
|
@ -227,20 +233,38 @@
|
||||||
$domain_input.addClass('error');
|
$domain_input.addClass('error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$form.find('input[type=submit]').hide()
|
$form.find('input[type=submit]').hide();
|
||||||
.after(tpl_registration_request({
|
this.renderRegistrationRequest(__('Cancel'));
|
||||||
cancel: __('Cancel'),
|
this.fetchRegistrationForm(domain);
|
||||||
info_message: __('Requesting a registration form from the XMPP server')
|
},
|
||||||
}));
|
|
||||||
$form.find('button.button-cancel').on('click', this.cancelRegistration.bind(this));
|
fetchRegistrationForm: function(domain_name) {
|
||||||
|
/* This is called with a domain name based on which, it fetches a
|
||||||
|
* registration form from the requested domain.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* (Domain name) domain_name - XMPP server domain
|
||||||
|
*/
|
||||||
this.reset({
|
this.reset({
|
||||||
domain: Strophe.getDomainFromJid(domain),
|
domain: Strophe.getDomainFromJid(domain_name),
|
||||||
_registering: true
|
_registering: true
|
||||||
});
|
});
|
||||||
_converse.connection.connect(this.domain, "", this.onRegistering.bind(this));
|
_converse.connection.connect(this.domain, "", this.onRegistering.bind(this));
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
renderRegistrationRequest: function(cancel_label) {
|
||||||
|
var form_help = document.querySelector('.form-help');
|
||||||
|
$(form_help).after(tpl_registration_request({
|
||||||
|
cancel: cancel_label,
|
||||||
|
info_message: _converse.__('Requesting a registration form from the XMPP server')
|
||||||
|
}));
|
||||||
|
if (!_converse.registration_domain) {
|
||||||
|
var cancel_button = document.querySelector('button.button-cancel');
|
||||||
|
cancel_button.addEventListener('click', this.cancelRegistration.bind(this));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
giveFeedback: function (message, klass) {
|
giveFeedback: function (message, klass) {
|
||||||
this.$('.reg-feedback').attr('class', 'reg-feedback').text(message);
|
this.$('.reg-feedback').attr('class', 'reg-feedback').text(message);
|
||||||
if (klass) {
|
if (klass) {
|
||||||
|
@ -349,6 +373,9 @@
|
||||||
$form.append('<input type="button" class="submit" value="'+__('Return')+'"/>');
|
$form.append('<input type="button" class="submit" value="'+__('Return')+'"/>');
|
||||||
$form.find('input[type=button]').on('click', this.cancelRegistration.bind(this));
|
$form.find('input[type=button]').on('click', this.cancelRegistration.bind(this));
|
||||||
}
|
}
|
||||||
|
if (_converse.registration_domain) {
|
||||||
|
$form.find('input[type=button]').hide();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
reportErrors: function (stanza) {
|
reportErrors: function (stanza) {
|
||||||
|
@ -390,6 +417,11 @@
|
||||||
if (ev && ev.preventDefault) { ev.preventDefault(); }
|
if (ev && ev.preventDefault) { ev.preventDefault(); }
|
||||||
_converse.connection.reset();
|
_converse.connection.reset();
|
||||||
this.render();
|
this.render();
|
||||||
|
if (_converse.registration_domain) {
|
||||||
|
this.renderRegistrationRequest(__('Retry'));
|
||||||
|
document.querySelector('button.button-cancel').onclick =
|
||||||
|
_.bind(this.fetchRegistrationForm, this, _converse.registration_domain);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
submitRegistrationForm : function (ev) {
|
submitRegistrationForm : function (ev) {
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
<form id="converse-register" class="pure-form converse-form">
|
<form id="converse-register" class="pure-form converse-form">
|
||||||
<span class="reg-feedback"></span>
|
<span class="reg-feedback"></span>
|
||||||
<label>{{{label_domain}}}</label>
|
<label>{{{label_domain}}}</label>
|
||||||
|
{[ if (default_domain) { ]}
|
||||||
|
<label>{{{default_domain}}}</label>
|
||||||
|
{[ } ]}
|
||||||
|
{[ if (!default_domain) { ]}
|
||||||
<input type="text" name="domain" placeholder="{{{domain_placeholder}}}">
|
<input type="text" name="domain" placeholder="{{{domain_placeholder}}}">
|
||||||
|
{[ } ]}
|
||||||
<p class="form-help">{{{help_providers}}} <a href="{{{href_providers}}}" class="url" target="_blank" rel="noopener">{{{help_providers_link}}}</a>.</p>
|
<p class="form-help">{{{help_providers}}} <a href="{{{href_providers}}}" class="url" target="_blank" rel="noopener">{{{help_providers_link}}}</a>.</p>
|
||||||
|
{[ if (!default_domain) { ]}
|
||||||
<input class="pure-button button-primary" type="submit" value="{{{label_register}}}">
|
<input class="pure-button button-primary" type="submit" value="{{{label_register}}}">
|
||||||
|
{[ } ]}
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
<span class="spinner login-submit"/>
|
<span class="spinner login-submit"/>
|
||||||
<p class="info">{{{info_message}}}</p>
|
<p class="info">{{{info_message}}}</p>
|
||||||
|
{[ if (cancel) { ]}
|
||||||
<button class="pure-button button-cancel hor_centered">{{{cancel}}}</button>
|
<button class="pure-button button-cancel hor_centered">{{{cancel}}}</button>
|
||||||
|
{[ } ]}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user