From 3c156218da9b8978b5e656182c5610d05f8577f6 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Tue, 19 Feb 2019 13:57:31 +0000 Subject: [PATCH 1/2] Allow captchas on Riot desktop builds --- src/components/views/auth/CaptchaForm.js | 29 ++++++------------------ src/i18n/strings/en_EN.json | 1 - 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/src/components/views/auth/CaptchaForm.js b/src/components/views/auth/CaptchaForm.js index ca450c5df4..d3b7d0bfe5 100644 --- a/src/components/views/auth/CaptchaForm.js +++ b/src/components/views/auth/CaptchaForm.js @@ -17,7 +17,6 @@ limitations under the License. 'use strict'; import React from 'react'; -import ReactDOM from 'react-dom'; import PropTypes from 'prop-types'; import { _t } from '../../../languageHandler'; @@ -61,29 +60,15 @@ module.exports = React.createClass({ } else { console.log("Loading recaptcha script..."); window.mx_on_recaptcha_loaded = () => {this._onCaptchaLoaded();}; - const protocol = global.location.protocol; + let protocol = global.location.protocol; if (protocol === "vector:") { - const 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 - ReactDOM.render(_t( - "Robot check is currently unavailable on desktop - please use a web browser", - {}, - { - 'a': (sub) => { - return { sub }; - }, - }), warning); - this.refs.recaptchaContainer.appendChild(warning); - } else { - const 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); + protocol = "https:"; } + const 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); } }, diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 9afcc07147..57a9501c5e 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1224,7 +1224,6 @@ "Sign in": "Sign in", "Login": "Login", "powered by Matrix": "powered by Matrix", - "Robot check is currently unavailable on desktop - please use a web browser": "Robot check is currently unavailable on desktop - please use a web browser", "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", "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.", From 1cde4abe6a703f813e010a561ede24378b750ec9 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Tue, 19 Feb 2019 13:59:15 +0000 Subject: [PATCH 2/2] Improve text layout above captcha --- src/components/views/auth/CaptchaForm.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/views/auth/CaptchaForm.js b/src/components/views/auth/CaptchaForm.js index d3b7d0bfe5..bb4785f299 100644 --- a/src/components/views/auth/CaptchaForm.js +++ b/src/components/views/auth/CaptchaForm.js @@ -126,8 +126,9 @@ module.exports = React.createClass({ return (
- { _t("This homeserver would like to make sure you are not a robot.") } -
+

{_t( + "This homeserver would like to make sure you are not a robot.", + )}

{ error }