summary refs log tree commit diff
path: root/webclient/login/register-controller.js
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2014-09-05 23:08:39 -0700
committerKegan Dougal <kegan@matrix.org>2014-09-05 23:08:39 -0700
commitb5749c75d90247ff2f7960fad909b7b4fb694b67 (patch)
treef601e0fab32f2b47d175cda0fa65952ca5baa014 /webclient/login/register-controller.js
parent80 chars please (diff)
downloadsynapse-b5749c75d90247ff2f7960fad909b7b4fb694b67.tar.xz
Reload captchas when they fail. Cleanup on success.
Diffstat (limited to 'webclient/login/register-controller.js')
-rw-r--r--webclient/login/register-controller.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/webclient/login/register-controller.js b/webclient/login/register-controller.js
index 96fffb364d..1ab50888df 100644
--- a/webclient/login/register-controller.js
+++ b/webclient/login/register-controller.js
@@ -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.";