Modified matrixService.register to specify if captcha results should be sent with the registration request. This is toggleable via useCaptcha in register-controller.

This commit is contained in:
Kegan Dougal 2014-09-05 13:56:36 -07:00
parent 0280176ccd
commit 130458385e
2 changed files with 28 additions and 6 deletions

View file

@ -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