From c80f7394617dcc44c3a608a3a51acde0f255f623 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 5 Sep 2014 17:36:09 -0700 Subject: [PATCH] Added webclient config.js for storing recaptcha public key. --- .gitignore | 2 ++ webclient/README | 18 +++++++++++++++--- webclient/index.html | 1 + webclient/login/register-controller.js | 15 +++++++++++++-- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index d2b93ef61f..dfe8dfedbf 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,6 @@ graph/*.svg graph/*.png graph/*.dot +webclient/config.js + uploads diff --git a/webclient/README b/webclient/README index 0f893b1712..9750d2706a 100644 --- a/webclient/README +++ b/webclient/README @@ -1,12 +1,24 @@ Basic Usage ----------- -The Synapse web client needs to be hosted by a basic HTTP server. - -You can use the Python simple HTTP server:: +The web client should automatically run when running the home server. Alternatively, you can run +it stand-alone: $ python -m SimpleHTTPServer 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/index.html b/webclient/index.html index fe62d95bb8..0981373134 100644 --- a/webclient/index.html +++ b/webclient/index.html @@ -17,6 +17,7 @@ + diff --git a/webclient/login/register-controller.js b/webclient/login/register-controller.js index 9d02f274df..96fffb364d 100644 --- a/webclient/login/register-controller.js +++ b/webclient/login/register-controller.js @@ -19,7 +19,7 @@ angular.module('RegisterController', ['matrixService']) function($scope, $rootScope, $location, matrixService, eventStreamService) { 'use strict'; - var useCaptcha = false; + var useCaptcha = true; // FIXME: factor out duplication with login-controller.js @@ -147,7 +147,18 @@ angular.module('RegisterController', ['matrixService']) var setupCaptcha = function() { console.log("Setting up ReCaptcha") - Recaptcha.create("6Le31_kSAAAAAK-54VKccKamtr-MFA_3WS1d_fGV", + var config = window.webClientConfig; + var public_key = undefined; + if (config === undefined) { + console.error("Couldn't find webClientConfig. Cannot get public key for captcha."); + } + else { + public_key = webClientConfig.recaptcha_public_key; + if (public_key === undefined) { + console.error("No public key defined for captcha!") + } + } + Recaptcha.create(public_key, "regcaptcha", { theme: "red",