Skip to content

Instantly share code, notes, and snippets.

@jamigibbs
Created June 11, 2019 22:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamigibbs/7ffda1db5abeb56744a827793a47f48b to your computer and use it in GitHub Desktop.
Save jamigibbs/7ffda1db5abeb56744a827793a47f48b to your computer and use it in GitHub Desktop.
/*
* 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