From bb6eeea0d8aa672fde93eac96e5fd8c9d905c786 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 19 Nov 2015 16:08:25 +0000 Subject: [PATCH] Factor out div ID name to avoid tight coupling with logic class. --- src/components/login/CaptchaForm.js | 8 +++++--- src/components/login/Registration.js | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/login/CaptchaForm.js b/src/components/login/CaptchaForm.js index f82ace8ec3..0bbf948835 100644 --- a/src/components/login/CaptchaForm.js +++ b/src/components/login/CaptchaForm.js @@ -19,6 +19,8 @@ limitations under the License. var React = require('react'); var sdk = require('matrix-react-sdk') +var DIV_ID = 'mx_recaptcha'; + /** * A pure UI component which displays a captcha form. */ @@ -26,7 +28,7 @@ module.exports = React.createClass({ displayName: 'CaptchaForm', propTypes: { - onCaptchaLoaded: React.PropTypes.func.isRequired + onCaptchaLoaded: React.PropTypes.func.isRequired // called with div id name }, getDefaultProps: function() { @@ -46,7 +48,7 @@ module.exports = React.createClass({ var scriptTag = document.createElement('script'); window.mx_on_recaptcha_loaded = function() { console.log("Loaded recaptcha script."); - self.props.onCaptchaLoaded(); + self.props.onCaptchaLoaded(DIV_ID); }; scriptTag.setAttribute( 'src', global.location.protocol+"//www.google.com/recaptcha/api.js?onload=mx_on_recaptcha_loaded&render=explicit" @@ -60,7 +62,7 @@ module.exports = React.createClass({ return (
This Home Server would like to make sure you are not a robot -
+
); } diff --git a/src/components/login/Registration.js b/src/components/login/Registration.js index 99b58ad145..54cbeeb080 100644 --- a/src/components/login/Registration.js +++ b/src/components/login/Registration.js @@ -154,8 +154,10 @@ module.exports = React.createClass({ }); }, - onCaptchaLoaded: function() { - this.registerLogic.tellStage("m.login.recaptcha", "loaded"); + onCaptchaLoaded: function(divIdName) { + this.registerLogic.tellStage("m.login.recaptcha", { + divId: divIdName + }); }, // TODO: