From 1b46ab7a8068cff04452d7c85fb65eab45987048 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Fri, 23 Dec 2016 14:35:40 +0000 Subject: [PATCH 1/5] blind fix for captcha on electron --- src/components/views/login/CaptchaForm.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/views/login/CaptchaForm.js b/src/components/views/login/CaptchaForm.js index 0e5922f464..16012837a2 100644 --- a/src/components/views/login/CaptchaForm.js +++ b/src/components/views/login/CaptchaForm.js @@ -54,8 +54,9 @@ module.exports = React.createClass({ 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', global.location.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); } From 386770a22a1047adcd55b1da21160806594fb736 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sat, 24 Dec 2016 03:15:30 +0000 Subject: [PATCH 2/5] 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 --- src/Signup.js | 2 +- src/SignupStages.js | 21 +++++++++------- .../structures/login/Registration.js | 1 + src/components/views/login/CaptchaForm.js | 24 ++++++++++++++----- 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/Signup.js b/src/Signup.js index a76919f34e..f148ac2419 100644 --- a/src/Signup.js +++ b/src/Signup.js @@ -191,7 +191,7 @@ class Register extends Signup { } } if (poll_for_success) { - return q.delay(5000).then(function() { + return q.delay(2000).then(function() { return self._tryRegister(client, authDict, poll_for_success); }); } else { diff --git a/src/SignupStages.js b/src/SignupStages.js index 283b11afef..06401da218 100644 --- a/src/SignupStages.js +++ b/src/SignupStages.js @@ -52,7 +52,13 @@ DummyStage.TYPE = "m.login.dummy"; class RecaptchaStage extends Stage { constructor(matrixClient, signupInstance) { super(RecaptchaStage.TYPE, matrixClient, signupInstance); - this.defer = q.defer(); // resolved with the captcha response + this.authDict = { + auth: { + type: 'm.login.recaptcha', + // we'll add in the response param if we get one from the local user. + }, + poll_for_success: true, + }; } // called when the recaptcha has been completed. @@ -60,16 +66,15 @@ class RecaptchaStage extends Stage { if (!data || !data.response) { return; } - this.defer.resolve({ - auth: { - type: 'm.login.recaptcha', - response: data.response, - } - }); + this.authDict.response = data.response; } complete() { - return this.defer.promise; + // we return the authDict with no response, telling Signup to keep polling + // the server in case the captcha is filled in on another window (e.g. by + // following a nextlink from an email signup). If the user completes the + // captcha locally, then we return at the next poll. + return q(this.authDict); } } RecaptchaStage.TYPE = "m.login.recaptcha"; diff --git a/src/components/structures/login/Registration.js b/src/components/structures/login/Registration.js index 5071a6b4c6..269aabed9b 100644 --- a/src/components/structures/login/Registration.js +++ b/src/components/structures/login/Registration.js @@ -273,6 +273,7 @@ module.exports = React.createClass({ if (serverParams && serverParams["m.login.recaptcha"]) { publicKey = serverParams["m.login.recaptcha"].public_key; } + registerStep = ( {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 using a web browser."; + 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 (
This Home Server would like to make sure you are not a robot +
{error}
From 7d42ef90d64a6b6e35b347d053238e9de746cec1 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sat, 24 Dec 2016 18:40:04 +0000 Subject: [PATCH 3/5] improve captcha warning --- src/components/views/login/CaptchaForm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/login/CaptchaForm.js b/src/components/views/login/CaptchaForm.js index 6b39d18c45..d50e0dee26 100644 --- a/src/components/views/login/CaptchaForm.js +++ b/src/components/views/login/CaptchaForm.js @@ -60,7 +60,7 @@ module.exports = React.createClass({ // * 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 using a web browser."; + warning.innerHTML = "Robot check is currently unavailable on desktop - please use a web browser."; this.refs.recaptchaContainer.appendChild(warning); } else { From 2e888f7f271e350bcbde7089c8ac801d39129e48 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sat, 24 Dec 2016 18:53:24 +0000 Subject: [PATCH 4/5] Prepare changelog for v0.8.3-electron --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e76fcd1a4..66b3002c4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +Changes in [0.8.3-electron](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v0.8.3-electron) (2016-12-24) +===================================================================================================================== +[Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v0.8.3...v0.8.3-electron) + + * Fix signup by working around the fact that reCapture doesn't work on electron + * Fix windows shortcut link + Changes in [0.8.3](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v0.8.3) (2016-12-22) =================================================================================================== [Full Changelog](https://github.com/matrix-org/matrix-react-sdk/compare/v0.8.2...v0.8.3) From 1976bb70bd5091c4b0852ef9eb690e4834d4ca60 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sat, 24 Dec 2016 18:53:24 +0000 Subject: [PATCH 5/5] v0.8.3-electron --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ed982bed72..dadf39e6d2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matrix-react-sdk", - "version": "0.8.3", + "version": "0.8.3-electron", "description": "SDK for matrix.org using React", "author": "matrix.org", "repository": {