Skip to content

Instantly share code, notes, and snippets.

@jamigibbs jamigibbs/vf-recaptcha-3.js Secret
Created Jun 11, 2019

Embed
What would you like to do?
/*
* If a message was received not from the expected origin, let's bail.
*/
if (event.origin !== hostURL){
return;
}
/*
* Let's check for a recaptcha token and send back the result to our component.
*/
if (event.data.action == "alohaCallingCAPTCHA"){
var token = document.getElementById("g-recaptcha-response").value;
if (token == ""){
parent.postMessage({
action: "alohaCallingCAPTCHA",
alohaResponseCAPTCHA : "NOK"
}, hostURL);
} else {
parent.postMessage({
action: "alohaCallingCAPTCHA",
alohaResponseCAPTCHA : "OK",
response: token
}, hostURL);
}
}
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.