diff options
author | Kegan Dougal <kegan@matrix.org> | 2014-09-05 23:32:51 -0700 |
---|---|---|
committer | Kegan Dougal <kegan@matrix.org> | 2014-09-05 23:32:51 -0700 |
commit | 1a298aad9c3bbc1f0c80c40a1518c29c511f9fb4 (patch) | |
tree | 8c27ca9b59021a5f9211cfb2c167ceaf083987d2 /webclient/components | |
parent | Fix generation of event ids so that they are consistent between local and rem... (diff) | |
parent | Added instructions for setting up captcha in an obviously named file. (diff) | |
download | synapse-1a298aad9c3bbc1f0c80c40a1518c29c511f9fb4.tar.xz |
Added captcha support on both the HS and web client.
Merge branch 'captcha' of github.com:matrix-org/synapse into develop
Diffstat (limited to 'webclient/components')
-rw-r--r-- | webclient/components/matrix/matrix-service.js | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/webclient/components/matrix/matrix-service.js b/webclient/components/matrix/matrix-service.js index 55cbd4bc14..b7e03657f0 100644 --- a/webclient/components/matrix/matrix-service.js +++ b/webclient/components/matrix/matrix-service.js @@ -84,15 +84,32 @@ angular.module('matrixService', []) prefix: prefixPath, // Register an user - register: function(user_name, password, threepidCreds) { + register: function(user_name, password, threepidCreds, useCaptcha) { // The REST path spec var path = "/register"; - - return doRequest("POST", path, undefined, { + + var data = { user_id: user_name, password: password, threepidCreds: threepidCreds - }); + }; + + if (useCaptcha) { + // Not all home servers will require captcha on signup, but if this flag is checked, + // send captcha information. + // TODO: Might be nice to make this a bit more flexible.. + var challengeToken = Recaptcha.get_challenge(); + var captchaEntry = Recaptcha.get_response(); + var captchaType = "m.login.recaptcha"; + + data.captcha = { + type: captchaType, + challenge: challengeToken, + response: captchaEntry + }; + } + + return doRequest("POST", path, undefined, data); }, // Create a room |