Fix race condition between our setup and Google's.
This commit is contained in:
parent
cedda40d8d
commit
c97cbc252e
@ -60,14 +60,25 @@ QR.captcha =
|
|||||||
|
|
||||||
$.globalEval '''
|
$.globalEval '''
|
||||||
(function() {
|
(function() {
|
||||||
var container = document.querySelector("#qr .captcha-container");
|
function render() {
|
||||||
container.dataset.widgetID = window.grecaptcha.render(container, {
|
var container = document.querySelector("#qr .captcha-container");
|
||||||
sitekey: '<%= meta.recaptchaKey %>',
|
container.dataset.widgetID = window.grecaptcha.render(container, {
|
||||||
theme: document.documentElement.classList.contains('tomorrow') ? 'dark' : 'light',
|
sitekey: '<%= meta.recaptchaKey %>',
|
||||||
callback: function(response) {
|
theme: document.documentElement.classList.contains('tomorrow') ? 'dark' : 'light',
|
||||||
window.dispatchEvent(new CustomEvent("captcha:success", {detail: response}));
|
callback: function(response) {
|
||||||
|
window.dispatchEvent(new CustomEvent("captcha:success", {detail: response}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (window.grecaptcha) {
|
||||||
|
render();
|
||||||
|
} else {
|
||||||
|
var cbNative = window.onRecaptchaLoaded;
|
||||||
|
window.onRecaptchaLoaded = function() {
|
||||||
|
render();
|
||||||
|
cbNative();
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
})();
|
})();
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user