Merge pull request #2663 from jryans/enable-captcha-desktop

Allow captchas on Riot desktop builds
This commit is contained in:
J. Ryan Stinnett 2019-02-19 18:20:15 +00:00 committed by GitHub
commit 6b46057283
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 25 deletions

View file

@ -17,7 +17,6 @@ limitations under the License.
'use strict'; 'use strict';
import React from 'react'; import React from 'react';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { _t } from '../../../languageHandler'; import { _t } from '../../../languageHandler';
@ -61,30 +60,16 @@ module.exports = React.createClass({
} else { } else {
console.log("Loading recaptcha script..."); console.log("Loading recaptcha script...");
window.mx_on_recaptcha_loaded = () => {this._onCaptchaLoaded();}; window.mx_on_recaptcha_loaded = () => {this._onCaptchaLoaded();};
const protocol = global.location.protocol; let protocol = global.location.protocol;
if (protocol === "vector:") { if (protocol === "vector:") {
const warning = document.createElement('div'); protocol = "https:";
// 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
ReactDOM.render(_t(
"Robot check is currently unavailable on desktop - please use a <a>web browser</a>",
{},
{
'a': (sub) => {
return <a target="_blank" rel="noopener" href='https://riot.im/app'>{ sub }</a>;
},
}), warning);
this.refs.recaptchaContainer.appendChild(warning);
} else {
const scriptTag = document.createElement('script'); const scriptTag = document.createElement('script');
scriptTag.setAttribute( scriptTag.setAttribute(
'src', protocol+"//www.google.com/recaptcha/api.js?onload=mx_on_recaptcha_loaded&render=explicit", 'src', `${protocol}//www.google.com/recaptcha/api.js?onload=mx_on_recaptcha_loaded&render=explicit`,
); );
this.refs.recaptchaContainer.appendChild(scriptTag); this.refs.recaptchaContainer.appendChild(scriptTag);
} }
}
}, },
componentWillUnmount: function() { componentWillUnmount: function() {
@ -141,8 +126,9 @@ module.exports = React.createClass({
return ( return (
<div ref="recaptchaContainer"> <div ref="recaptchaContainer">
{ _t("This homeserver would like to make sure you are not a robot.") } <p>{_t(
<br /> "This homeserver would like to make sure you are not a robot.",
)}</p>
<div id={DIV_ID}></div> <div id={DIV_ID}></div>
{ error } { error }
</div> </div>

View file

@ -1224,7 +1224,6 @@
"Sign in": "Sign in", "Sign in": "Sign in",
"Login": "Login", "Login": "Login",
"powered by Matrix": "powered by Matrix", "powered by Matrix": "powered by Matrix",
"Robot check is currently unavailable on desktop - please use a <a>web browser</a>": "Robot check is currently unavailable on desktop - please use a <a>web browser</a>",
"This homeserver would like to make sure you are not a robot.": "This homeserver would like to make sure you are not a robot.", "This homeserver would like to make sure you are not a robot.": "This homeserver would like to make sure you are not a robot.",
"Custom Server Options": "Custom Server Options", "Custom Server Options": "Custom Server Options",
"You can use the custom server options to sign into other Matrix servers by specifying a different homeserver URL. This allows you to use this app with an existing Matrix account on a different homeserver.": "You can use the custom server options to sign into other Matrix servers by specifying a different homeserver URL. This allows you to use this app with an existing Matrix account on a different homeserver.", "You can use the custom server options to sign into other Matrix servers by specifying a different homeserver URL. This allows you to use this app with an existing Matrix account on a different homeserver.": "You can use the custom server options to sign into other Matrix servers by specifying a different homeserver URL. This allows you to use this app with an existing Matrix account on a different homeserver.",