Bugfix. Endless spinner when trying to log in
after rendering the registration form.
This commit is contained in:
parent
d3a8032f61
commit
9fc61d9302
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
## 3.0.1 (Unreleased)
|
## 3.0.1 (Unreleased)
|
||||||
|
|
||||||
|
- Bugfix. Endless spinner when trying to log in after rendering the registration form. [jcbrand]
|
||||||
- #585 Duplicate contact created due to JID case sensivity [saganshul]
|
- #585 Duplicate contact created due to JID case sensivity [saganshul]
|
||||||
- #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]
|
||||||
|
|
|
@ -96,7 +96,6 @@
|
||||||
_converse.connection._connect_cb(test_utils.createRequest(stanza));
|
_converse.connection._connect_cb(test_utils.createRequest(stanza));
|
||||||
|
|
||||||
expect(registerview.getRegistrationFields).toHaveBeenCalled();
|
expect(registerview.getRegistrationFields).toHaveBeenCalled();
|
||||||
expect(_converse.connection.connected).toBeTruthy();
|
|
||||||
|
|
||||||
stanza = $iq({
|
stanza = $iq({
|
||||||
'type': 'result',
|
'type': 'result',
|
||||||
|
|
|
@ -348,7 +348,7 @@
|
||||||
$sibling.removeClass('current');
|
$sibling.removeClass('current');
|
||||||
$tab.addClass('current');
|
$tab.addClass('current');
|
||||||
$tab_panel.removeClass('hidden');
|
$tab_panel.removeClass('hidden');
|
||||||
if (_converse.connection.connected) {
|
if (!_.isUndefined(_converse.chatboxes.browserStorage)) {
|
||||||
this.model.save({'active-panel': $tab.data('id')});
|
this.model.save({'active-panel': $tab.data('id')});
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
|
@ -446,6 +446,7 @@
|
||||||
jid = Strophe.getBareJidFromJid(jid).toLowerCase()+'/'+resource;
|
jid = Strophe.getBareJidFromJid(jid).toLowerCase()+'/'+resource;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_converse.connection.reset();
|
||||||
_converse.connection.connect(jid, password, _converse.onConnectStatusChanged);
|
_converse.connection.connect(jid, password, _converse.onConnectStatusChanged);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -1908,6 +1908,7 @@
|
||||||
"Either when calling converse.initialize, or when calling " +
|
"Either when calling converse.initialize, or when calling " +
|
||||||
"_converse.api.user.login.");
|
"_converse.api.user.login.");
|
||||||
}
|
}
|
||||||
|
this.connection.reset();
|
||||||
this.connection.connect(this.jid.toLowerCase(), null, this.onConnectStatusChanged);
|
this.connection.connect(this.jid.toLowerCase(), null, this.onConnectStatusChanged);
|
||||||
} else if (this.authentication === _converse.LOGIN) {
|
} else if (this.authentication === _converse.LOGIN) {
|
||||||
var password = _converse.connection.pass || this.password;
|
var password = _converse.connection.pass || this.password;
|
||||||
|
@ -1926,6 +1927,7 @@
|
||||||
} else {
|
} else {
|
||||||
this.jid = Strophe.getBareJidFromJid(this.jid).toLowerCase()+'/'+resource;
|
this.jid = Strophe.getBareJidFromJid(this.jid).toLowerCase()+'/'+resource;
|
||||||
}
|
}
|
||||||
|
this.connection.reset();
|
||||||
this.connection.connect(this.jid, password, this.onConnectStatusChanged);
|
this.connection.connect(this.jid, password, this.onConnectStatusChanged);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -2006,6 +2008,7 @@
|
||||||
this.roster.off().reset(); // Removes roster contacts
|
this.roster.off().reset(); // Removes roster contacts
|
||||||
}
|
}
|
||||||
this.chatboxes.remove(); // Don't call off(), events won't get re-registered upon reconnect.
|
this.chatboxes.remove(); // Don't call off(), events won't get re-registered upon reconnect.
|
||||||
|
delete this.chatboxes.browserStorage;
|
||||||
if (this.features) {
|
if (this.features) {
|
||||||
this.features.reset();
|
this.features.reset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
// Other necessary globals
|
// Other necessary globals
|
||||||
var $ = converse.env.jQuery,
|
var $ = converse.env.jQuery,
|
||||||
_ = converse.env._;
|
_ = converse.env._;
|
||||||
|
|
||||||
// Add Strophe Namespaces
|
// Add Strophe Namespaces
|
||||||
Strophe.addNamespace('REGISTER', 'jabber:iq:register');
|
Strophe.addNamespace('REGISTER', 'jabber:iq:register');
|
||||||
|
|
||||||
|
@ -60,6 +60,17 @@
|
||||||
|
|
||||||
ControlBoxView: {
|
ControlBoxView: {
|
||||||
|
|
||||||
|
switchTab: function (ev) {
|
||||||
|
var _converse = this.__super__._converse;
|
||||||
|
var result = this.__super__.switchTab.apply(this, arguments);
|
||||||
|
if (_converse.registration_domain &&
|
||||||
|
ev.target.getAttribute('data-id') === "register" &&
|
||||||
|
!this.model.get('registration_form_rendered')) {
|
||||||
|
this.registerpanel.fetchRegistrationForm(_converse.registration_domain);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
|
||||||
renderLoginPanel: function () {
|
renderLoginPanel: function () {
|
||||||
/* Also render a registration panel, when rendering the
|
/* Also render a registration panel, when rendering the
|
||||||
* login panel.
|
* login panel.
|
||||||
|
@ -69,14 +80,9 @@
|
||||||
if (_converse.allow_registration) {
|
if (_converse.allow_registration) {
|
||||||
this.registerpanel = new _converse.RegisterPanel({
|
this.registerpanel = new _converse.RegisterPanel({
|
||||||
'$parent': this.$el.find('.controlbox-panes'),
|
'$parent': this.$el.find('.controlbox-panes'),
|
||||||
'model': this
|
'model': this.model
|
||||||
});
|
});
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -119,6 +125,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function () {
|
render: function () {
|
||||||
|
this.model.set('registration_form_rendered', false);
|
||||||
this.$parent.append(this.$el.html(
|
this.$parent.append(this.$el.html(
|
||||||
tpl_register_panel({
|
tpl_register_panel({
|
||||||
'default_domain': _converse.registration_domain,
|
'default_domain': _converse.registration_domain,
|
||||||
|
@ -158,7 +165,6 @@
|
||||||
* (Strophe.Request) req - The current request
|
* (Strophe.Request) req - The current request
|
||||||
* (Function) callback
|
* (Function) callback
|
||||||
*/
|
*/
|
||||||
_converse.log("sendQueryStanza was called");
|
|
||||||
var conn = _converse.connection;
|
var conn = _converse.connection;
|
||||||
conn.connected = true;
|
conn.connected = true;
|
||||||
|
|
||||||
|
@ -176,13 +182,16 @@
|
||||||
if (register.length === 0) {
|
if (register.length === 0) {
|
||||||
conn._changeConnectStatus(
|
conn._changeConnectStatus(
|
||||||
Strophe.Status.REGIFAIL,
|
Strophe.Status.REGIFAIL,
|
||||||
__('Sorry, the given provider does not support in band account registration. Please try with a different provider.')
|
__("Sorry, the given provider does not support in "+
|
||||||
|
"band account registration. Please try with a "+
|
||||||
|
"different provider.")
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Send an IQ stanza to get all required data fields
|
// Send an IQ stanza to get all required data fields
|
||||||
conn._addSysHandler(this.onRegistrationFields.bind(this), null, "iq", null, null);
|
conn._addSysHandler(this.onRegistrationFields.bind(this), null, "iq", null, null);
|
||||||
conn.send($iq({type: "get"}).c("query", {xmlns: Strophe.NS.REGISTER}).tree());
|
conn.send($iq({type: "get"}).c("query", {xmlns: Strophe.NS.REGISTER}).tree());
|
||||||
|
conn.connected = false;
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -234,31 +243,34 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$form.find('input[type=submit]').hide();
|
$form.find('input[type=submit]').hide();
|
||||||
this.renderRegistrationRequest(__('Cancel'));
|
this.fetchRegistrationForm(domain, __('Cancel'));
|
||||||
this.fetchRegistrationForm(domain);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
fetchRegistrationForm: function(domain_name) {
|
fetchRegistrationForm: function (domain_name, cancel_label) {
|
||||||
/* This is called with a domain name based on which, it fetches a
|
/* This is called with a domain name based on which, it fetches a
|
||||||
* registration form from the requested domain.
|
* registration form from the requested domain.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* (Domain name) domain_name - XMPP server domain
|
* (Domain name) domain_name - XMPP server domain
|
||||||
*/
|
*/
|
||||||
|
this.renderRegistrationRequest(cancel_label);
|
||||||
this.reset({
|
this.reset({
|
||||||
domain: Strophe.getDomainFromJid(domain_name),
|
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) {
|
renderRegistrationRequest: function (cancel_label) {
|
||||||
var form_help = document.querySelector('.form-help');
|
var form = this.el.querySelector('#converse-register');
|
||||||
$(form_help).after(tpl_registration_request({
|
utils.createElementsFromString(
|
||||||
cancel: cancel_label,
|
form,
|
||||||
info_message: _converse.__('Requesting a registration form from the XMPP server')
|
tpl_registration_request({
|
||||||
}));
|
cancel: cancel_label,
|
||||||
|
info_message: _converse.__('Requesting a registration form from the XMPP server')
|
||||||
|
})
|
||||||
|
);
|
||||||
if (!_converse.registration_domain) {
|
if (!_converse.registration_domain) {
|
||||||
var cancel_button = document.querySelector('button.button-cancel');
|
var cancel_button = document.querySelector('button.button-cancel');
|
||||||
cancel_button.addEventListener('click', this.cancelRegistration.bind(this));
|
cancel_button.addEventListener('click', this.cancelRegistration.bind(this));
|
||||||
|
@ -325,7 +337,9 @@
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* (XMLElement) stanza - The IQ stanza received from the XMPP server.
|
* (XMLElement) stanza - The IQ stanza received from the XMPP server.
|
||||||
*/
|
*/
|
||||||
var $form= this.$('form'),
|
this.model.set('registration_form_rendered', true);
|
||||||
|
|
||||||
|
var $form = this.$('form'),
|
||||||
$stanza = $(stanza),
|
$stanza = $(stanza),
|
||||||
$fields, $input;
|
$fields, $input;
|
||||||
$form.empty().append(tpl_registration_form({
|
$form.empty().append(tpl_registration_form({
|
||||||
|
@ -416,15 +430,18 @@
|
||||||
*/
|
*/
|
||||||
if (ev && ev.preventDefault) { ev.preventDefault(); }
|
if (ev && ev.preventDefault) { ev.preventDefault(); }
|
||||||
_converse.connection.reset();
|
_converse.connection.reset();
|
||||||
|
this.model.set('registration_form_rendered', false);
|
||||||
this.render();
|
this.render();
|
||||||
if (_converse.registration_domain) {
|
if (_converse.registration_domain) {
|
||||||
this.renderRegistrationRequest(__('Retry'));
|
|
||||||
document.querySelector('button.button-cancel').onclick =
|
document.querySelector('button.button-cancel').onclick =
|
||||||
_.bind(this.fetchRegistrationForm, this, _converse.registration_domain);
|
_.bind(
|
||||||
|
this.fetchRegistrationForm, this,
|
||||||
|
_converse.registration_domain, __('Retry')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
submitRegistrationForm : function (ev) {
|
submitRegistrationForm: function (ev) {
|
||||||
/* Handler, when the user submits the registration form.
|
/* Handler, when the user submits the registration form.
|
||||||
* Provides form error feedback or starts the registration
|
* Provides form error feedback or starts the registration
|
||||||
* process.
|
* process.
|
||||||
|
@ -456,6 +473,7 @@
|
||||||
iq.c($input.attr('name'), {}, $input.val());
|
iq.c($input.attr('name'), {}, $input.val());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
this.model.set('registration_form_rendered', false);
|
||||||
_converse.connection._addSysHandler(this._onRegisterIQ.bind(this), null, "iq", null, null);
|
_converse.connection._addSysHandler(this._onRegisterIQ.bind(this), null, "iq", null, null);
|
||||||
_converse.connection.send(iq);
|
_converse.connection.send(iq);
|
||||||
this.setFields(iq.tree());
|
this.setFields(iq.tree());
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
<li><a class="current" href="#login-dialog">{{{label_sign_in}}}</a></li>
|
<li><a class="current" data-id="login" href="#login-dialog">{{{label_sign_in}}}</a></li>
|
||||||
|
|
|
@ -2,13 +2,11 @@
|
||||||
<span class="reg-feedback"></span>
|
<span class="reg-feedback"></span>
|
||||||
<label>{{{label_domain}}}</label>
|
<label>{{{label_domain}}}</label>
|
||||||
{[ if (default_domain) { ]}
|
{[ if (default_domain) { ]}
|
||||||
<label>{{{default_domain}}}</label>
|
{{{default_domain}}}
|
||||||
{[ } ]}
|
{[ } ]}
|
||||||
{[ if (!default_domain) { ]}
|
{[ 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>
|
<input class="pure-button button-primary" type="submit" value="{{{label_register}}}">
|
||||||
{[ if (!default_domain) { ]}
|
|
||||||
<input class="pure-button button-primary" type="submit" value="{{{label_register}}}">
|
|
||||||
{[ } ]}
|
{[ } ]}
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
<li><a class="s" href="#register">{{{label_register}}}</a></li>
|
<li><a class="s" data-id="register" href="#register">{{{label_register}}}</a></li>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<span class="spinner login-submit"/>
|
<span class="spinner login-submit"></span>
|
||||||
<p class="info">{{{info_message}}}</p>
|
<p class="info">{{{info_message}}}</p>
|
||||||
{[ if (cancel) { ]}
|
{[ if (cancel) { ]}
|
||||||
<button class="pure-button button-cancel hor_centered">{{{cancel}}}</button>
|
<button class="pure-button button-cancel hor_centered">{{{cancel}}}</button>
|
||||||
|
|
16
src/utils.js
16
src/utils.js
|
@ -444,5 +444,21 @@
|
||||||
return !(utils.contains(attr, query)(item));
|
return !(utils.contains(attr, query)(item));
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
utils.createElementsFromString = function (element, html) {
|
||||||
|
// http://stackoverflow.com/questions/9334645/create-node-from-markup-string
|
||||||
|
var frag = document.createDocumentFragment(),
|
||||||
|
tmp = document.createElement('body'), child;
|
||||||
|
tmp.innerHTML = html;
|
||||||
|
// Append elements in a loop to a DocumentFragment, so that the browser does
|
||||||
|
// not re-render the document for each node
|
||||||
|
while (child = tmp.firstChild) { // eslint-disable-line no-cond-assign
|
||||||
|
frag.appendChild(child);
|
||||||
|
}
|
||||||
|
element.appendChild(frag); // Now, append all elements at once
|
||||||
|
frag = tmp = null;
|
||||||
|
}
|
||||||
|
|
||||||
return utils;
|
return utils;
|
||||||
}));
|
}));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user