diff options
Diffstat (limited to 'webclient')
-rw-r--r-- | webclient/CAPTCHA_SETUP | 46 | ||||
-rw-r--r-- | webclient/README | 11 | ||||
-rw-r--r-- | webclient/login/register-controller.js | 8 |
3 files changed, 54 insertions, 11 deletions
diff --git a/webclient/CAPTCHA_SETUP b/webclient/CAPTCHA_SETUP new file mode 100644 index 0000000000..ebc8a5f3b0 --- /dev/null +++ b/webclient/CAPTCHA_SETUP @@ -0,0 +1,46 @@ +Captcha can be enabled for this web client / home server. This file explains how to do that. +The captcha mechanism used is Google's ReCaptcha. This requires API keys from Google. + +Getting keys +------------ +Requires a public/private key pair from: + +https://developers.google.com/recaptcha/ + + +Setting Private ReCaptcha Key +----------------------------- +The private key is a config option on the home server config. If it is not +visible, you can generate it via --generate-config. Set the following value: + + recaptcha_private_key: YOUR_PRIVATE_KEY + +In addition, you MUST enable captchas via: + + enable_registration_captcha: true + +Setting Public ReCaptcha Key +---------------------------- +The web client will look for the global variable webClientConfig for config +options. You should put your ReCaptcha public key there like so: + +webClientConfig = { + useCaptcha: true, + recaptcha_public_key: "YOUR_PUBLIC_KEY" +} + +This should be put in webclient/config.js which is already .gitignored, rather +than in the web client source files. You MUST set useCaptcha to true else a +ReCaptcha widget will not be generated. + +Configuring IP used for auth +---------------------------- +The ReCaptcha API requires that the IP address of the user who solved the +captcha is sent. If the client is connecting through a proxy or load balancer, +it may be required to use the X-Forwarded-For (XFF) header instead of the origin +IP address. This can be configured as an option on the home server like so: + + captcha_ip_origin_is_x_forwarded: true + + + diff --git a/webclient/README b/webclient/README index 9750d2706a..13224c3d07 100644 --- a/webclient/README +++ b/webclient/README @@ -11,14 +11,3 @@ Then, open this URL in a WEB browser:: http://127.0.0.1:8000/ -ReCaptcha Keys --------------- -The web client will look for the global variable webClientConfig for config options. You should -put your ReCaptcha public key there like so: - -webClientConfig = { - recaptcha_public_key: "YOUR_PUBLIC_KEY" -} - -This should be put in webclient/config.js which is already .gitignored, rather than in the web -client source files. diff --git a/webclient/login/register-controller.js b/webclient/login/register-controller.js index 1ab50888df..b3c0c21335 100644 --- a/webclient/login/register-controller.js +++ b/webclient/login/register-controller.js @@ -19,7 +19,11 @@ angular.module('RegisterController', ['matrixService']) function($scope, $rootScope, $location, matrixService, eventStreamService) { 'use strict'; + var config = window.webClientConfig; var useCaptcha = true; + if (config !== undefined) { + useCaptcha = config.useCaptcha; + } // FIXME: factor out duplication with login-controller.js @@ -132,6 +136,10 @@ angular.module('RegisterController', ['matrixService']) else if (error.data.errcode == "M_CAPTCHA_INVALID") { $scope.feedback = "Failed captcha."; } + else if (error.data.errcode == "M_CAPTCHA_NEEDED") { + $scope.feedback = "Captcha is required on this home " + + "server."; + } } else if (error.status === 0) { $scope.feedback = "Unable to talk to the server."; |