diff options
author | Kegan Dougal <kegan@matrix.org> | 2014-09-05 13:56:36 -0700 |
---|---|---|
committer | Kegan Dougal <kegan@matrix.org> | 2014-09-05 13:56:36 -0700 |
commit | 130458385e919d886fcdfc4203354e93e9e8f1b1 (patch) | |
tree | adeeb7058a9722b04f84230e2e75ac90567b4c9b /webclient/components | |
parent | Added basic captcha, not hooked up (diff) | |
download | synapse-130458385e919d886fcdfc4203354e93e9e8f1b1.tar.xz |
Modified matrixService.register to specify if captcha results should be sent with the registration request. This is toggleable via useCaptcha in register-controller.
Diffstat (limited to 'webclient/components')
-rw-r--r-- | webclient/components/matrix/matrix-service.js | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/webclient/components/matrix/matrix-service.js b/webclient/components/matrix/matrix-service.js index 8a0223979c..4754dc87da 100644 --- a/webclient/components/matrix/matrix-service.js +++ b/webclient/components/matrix/matrix-service.js @@ -84,15 +84,33 @@ 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 + }; + console.log("Sending Captcha info: " + JSON.stringify(data.captcha)); + } + + return doRequest("POST", path, undefined, data); }, // Create a room |