ask electron users to do captchas in a web browser.

This will happen anyway when they follow email verification links.
make captchas poll for success so if they are completed elsewhere, electron moves on
This commit is contained in:
Matthew Hodgson 2016-12-24 03:15:30 +00:00
parent b1c4c759f4
commit 69b277b282
4 changed files with 33 additions and 15 deletions

View file

@ -273,6 +273,7 @@ module.exports = React.createClass({
if (serverParams && serverParams["m.login.recaptcha"]) {
publicKey = serverParams["m.login.recaptcha"].public_key;
}
registerStep = (
<CaptchaForm sitePublicKey={publicKey}
onCaptchaResponse={this.onCaptchaResponse}

View file

@ -52,13 +52,24 @@ module.exports = React.createClass({
this._onCaptchaLoaded();
} else {
console.log("Loading recaptcha script...");
var scriptTag = document.createElement('script');
window.mx_on_recaptcha_loaded = () => {this._onCaptchaLoaded()};
var protocol = global.location.protocol === "file:" ? "https:" : global.location.protocol;
scriptTag.setAttribute(
'src', protocol+"//www.google.com/recaptcha/api.js?onload=mx_on_recaptcha_loaded&render=explicit"
);
this.refs.recaptchaContainer.appendChild(scriptTag);
var protocol = global.location.protocol;
if (protocol === "file:") {
var warning = document.createElement('div');
// XXX: fix hardcoded app URL. Better solutions include:
// * jumping straight to a hosted captcha page (but we don't support that yet)
// * embedding the captcha in an iframe (if that works)
// * using a better captcha lib
warning.innerHTML = "Robot check is currently unavailable on desktop - please sign up <a href='https://riot.im/app'>using a web browser</a>.";
this.refs.recaptchaContainer.appendChild(warning);
}
else {
var scriptTag = document.createElement('script');
scriptTag.setAttribute(
'src', protocol+"//www.google.com/recaptcha/api.js?onload=mx_on_recaptcha_loaded&render=explicit"
);
this.refs.recaptchaContainer.appendChild(scriptTag);
}
}
},
@ -107,6 +118,7 @@ module.exports = React.createClass({
return (
<div ref="recaptchaContainer">
This Home Server would like to make sure you are not a robot
<br/>
<div id={DIV_ID}></div>
{error}
</div>