0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-10-17 22:09:01 +02:00

Reload captchas when they fail. Cleanup on success.

This commit is contained in:
Kegan Dougal 2014-09-05 23:08:39 -07:00
parent 3ea6f01b4e
commit b5749c75d9
2 changed files with 11 additions and 2 deletions

View file

@ -62,8 +62,8 @@ class RegistrationHandler(BaseHandler):
captcha_info["response"] captcha_info["response"]
) )
if not captcha_response["valid"]: if not captcha_response["valid"]:
logger.info("Invalid captcha entered from %s", logger.info("Invalid captcha entered from %s. Error: %s",
captcha_info["ip"]) captcha_info["ip"], captcha_response["error_url"])
raise InvalidCaptchaError( raise InvalidCaptchaError(
error_url=captcha_response["error_url"] error_url=captcha_response["error_url"]
) )

View file

@ -92,6 +92,9 @@ angular.module('RegisterController', ['matrixService'])
matrixService.register(mxid, password, threepidCreds, useCaptcha).then( matrixService.register(mxid, password, threepidCreds, useCaptcha).then(
function(response) { function(response) {
$scope.feedback = "Success"; $scope.feedback = "Success";
if (useCaptcha) {
Recaptcha.destroy();
}
// Update the current config // Update the current config
var config = matrixService.config(); var config = matrixService.config();
angular.extend(config, { angular.extend(config, {
@ -118,11 +121,17 @@ angular.module('RegisterController', ['matrixService'])
}, },
function(error) { function(error) {
console.trace("Registration error: "+error); console.trace("Registration error: "+error);
if (useCaptcha) {
Recaptcha.reload();
}
if (error.data) { if (error.data) {
if (error.data.errcode === "M_USER_IN_USE") { if (error.data.errcode === "M_USER_IN_USE") {
$scope.feedback = "Username already taken."; $scope.feedback = "Username already taken.";
$scope.reenter_username = true; $scope.reenter_username = true;
} }
else if (error.data.errcode == "M_CAPTCHA_INVALID") {
$scope.feedback = "Failed captcha.";
}
} }
else if (error.status === 0) { else if (error.status === 0) {
$scope.feedback = "Unable to talk to the server."; $scope.feedback = "Unable to talk to the server.";