Load the Recaptcha script if we have a container for it
This is complex enough that the Registration component shouldn't have to care about it, so it should probably be split into a pure UI component.
This commit is contained in:
parent
5424567a66
commit
bc55959fad
1 changed files with 19 additions and 3 deletions
|
@ -48,25 +48,41 @@ module.exports = React.createClass({
|
||||||
this.dispatcherRef = dis.register(this.onAction);
|
this.dispatcherRef = dis.register(this.onAction);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
componentDidUpdate: function() {
|
||||||
|
// Just putting a script tag into the returned jsx doesn't work, annoyingly,
|
||||||
|
// so we do this instead.
|
||||||
|
var self = this;
|
||||||
|
if (this.refs.recaptchaContainer) {
|
||||||
|
console.log("Loading recaptcha script...");
|
||||||
|
var scriptTag = document.createElement('script');
|
||||||
|
window.mx_on_recaptcha_loaded = function() {
|
||||||
|
console.log("Loaded recaptcha script.");
|
||||||
|
self.props.registerLogic.tellStage("m.login.recaptcha", "loaded");
|
||||||
|
};
|
||||||
|
scriptTag.setAttribute(
|
||||||
|
'src', global.location.protocol+"//www.google.com/recaptcha/api.js?onload=mx_on_recaptcha_loaded&render=explicit"
|
||||||
|
);
|
||||||
|
this.refs.recaptchaContainer.appendChild(scriptTag);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
componentWillUnmount: function() {
|
componentWillUnmount: function() {
|
||||||
dis.unregister(this.dispatcherRef);
|
dis.unregister(this.dispatcherRef);
|
||||||
},
|
},
|
||||||
|
|
||||||
onHsUrlChanged: function(newHsUrl) {
|
onHsUrlChanged: function(newHsUrl) {
|
||||||
this.props.registerLogic.setHomeserverUrl(newHsUrl);
|
this.props.registerLogic.setHomeserverUrl(newHsUrl);
|
||||||
this.forceUpdate(); // registration state may have changed.
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onIsUrlChanged: function(newIsUrl) {
|
onIsUrlChanged: function(newIsUrl) {
|
||||||
this.props.registerLogic.setIdentityServerUrl(newIsUrl);
|
this.props.registerLogic.setIdentityServerUrl(newIsUrl);
|
||||||
this.forceUpdate(); // registration state may have changed.
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onAction: function(payload) {
|
onAction: function(payload) {
|
||||||
if (payload.action !== "registration_step_update") {
|
if (payload.action !== "registration_step_update") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.forceUpdate();
|
this.forceUpdate(); // registration state has changed.
|
||||||
},
|
},
|
||||||
|
|
||||||
onFormSubmit: function(formVals) {
|
onFormSubmit: function(formVals) {
|
||||||
|
|
Loading…
Reference in a new issue