Skip to content
Snippets Groups Projects
Commit b5749c75 authored by Kegan Dougal's avatar Kegan Dougal
Browse files

Reload captchas when they fail. Cleanup on success.

parent 3ea6f01b
No related branches found
No related tags found
No related merge requests found
......@@ -62,8 +62,8 @@ class RegistrationHandler(BaseHandler):
captcha_info["response"]
)
if not captcha_response["valid"]:
logger.info("Invalid captcha entered from %s",
captcha_info["ip"])
logger.info("Invalid captcha entered from %s. Error: %s",
captcha_info["ip"], captcha_response["error_url"])
raise InvalidCaptchaError(
error_url=captcha_response["error_url"]
)
......
......@@ -92,6 +92,9 @@ angular.module('RegisterController', ['matrixService'])
matrixService.register(mxid, password, threepidCreds, useCaptcha).then(
function(response) {
$scope.feedback = "Success";
if (useCaptcha) {
Recaptcha.destroy();
}
// Update the current config
var config = matrixService.config();
angular.extend(config, {
......@@ -118,11 +121,17 @@ angular.module('RegisterController', ['matrixService'])
},
function(error) {
console.trace("Registration error: "+error);
if (useCaptcha) {
Recaptcha.reload();
}
if (error.data) {
if (error.data.errcode === "M_USER_IN_USE") {
$scope.feedback = "Username already taken.";
$scope.reenter_username = true;
}
else if (error.data.errcode == "M_CAPTCHA_INVALID") {
$scope.feedback = "Failed captcha.";
}
}
else if (error.status === 0) {
$scope.feedback = "Unable to talk to the server.";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment