mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-02-17 00:21:20 -05:00
Only load the captcha js if it hasn't been loaded yet.
This commit is contained in:
parent
350f6e6bab
commit
f5a44c3458
1 changed files with 15 additions and 0 deletions
|
@ -32,6 +32,7 @@ class EmailStep extends React.Component {
|
|||
}
|
||||
|
||||
componentDidMount () {
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
// automatically start with focus on username field
|
||||
if (this.emailInput) this.emailInput.focus();
|
||||
|
@ -45,6 +46,20 @@ class EmailStep extends React.Component {
|
|||
script.onerror = this.onCaptchaError;
|
||||
script.src = `https://www.recaptcha.net/recaptcha/api.js?onload=grecaptchaOnLoad&render=explicit&hl=${window._locale}`;
|
||||
document.body.appendChild(script);
|
||||
=======
|
||||
// If grecaptcha doesn't exist on window, we havent loaded the captcha js yet. Load it.
|
||||
if (!window.grecaptcha) {
|
||||
// ReCaptcha calls a callback when the grecatpcha object is usable. That callback
|
||||
// needs to be global so set it on the window.
|
||||
window.grecaptchaOnLoad = this.onCaptchaLoad;
|
||||
// Load Google ReCaptcha script.
|
||||
const script = document.createElement('script');
|
||||
script.async = true;
|
||||
script.onerror = this.onCaptchaError;
|
||||
script.src = `https://www.recaptcha.net/recaptcha/api.js?onload=grecaptchaOnLoad&render=explicit&hl=${window._locale}`;
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
>>>>>>> Only load the captcha js if it hasn't been loaded yet.
|
||||
}
|
||||
componentWillUnmount () {
|
||||
window.grecaptchaOnLoad = null;
|
||||
|
|
Loading…
Reference in a new issue