summary refs log tree commit diff
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2014-09-15 14:52:39 +0100
committerKegan Dougal <kegan@matrix.org>2014-09-15 14:52:39 +0100
commit04fbda46ddb722f64f9b0d702b41cc22569e9b12 (patch)
treef4f744e61e56bf54b427908375997154a9373d39
parentUpdated webclient to support the new registration logic. (diff)
downloadsynapse-04fbda46ddb722f64f9b0d702b41cc22569e9b12.tar.xz
Make captcha work again with the new registration logic.
Diffstat (limited to '')
-rw-r--r--synapse/rest/register.py1
-rw-r--r--webclient/components/matrix/matrix-service.js22
2 files changed, 22 insertions, 1 deletions
diff --git a/synapse/rest/register.py b/synapse/rest/register.py
index 8036c3c406..fe8f0ed23f 100644
--- a/synapse/rest/register.py
+++ b/synapse/rest/register.py
@@ -133,6 +133,7 @@ class RegisterRestServlet(RestServlet):
         logger.debug("Removing session %s", session)
         self.sessions.pop(session["id"])
 
+    @defer.inlineCallbacks
     def _do_recaptcha(self, request, register_json, session):
         if not self.hs.config.enable_registration_captcha:
             raise SynapseError(400, "Captcha not required.")
diff --git a/webclient/components/matrix/matrix-service.js b/webclient/components/matrix/matrix-service.js
index d7d278a7f6..35ebca961c 100644
--- a/webclient/components/matrix/matrix-service.js
+++ b/webclient/components/matrix/matrix-service.js
@@ -154,6 +154,13 @@ angular.module('matrixService', [])
                                 }
                                 if (!useCaptcha && regType == "m.login.recaptcha") {
                                     console.error("Web client setup to not use captcha, but HS demands a captcha.");
+                                    deferred.reject({
+                                        data: {
+                                            errcode: "M_CAPTCHA_NEEDED",
+                                            error: "Home server requires a captcha."
+                                        }
+                                    });
+                                    return;
                                 }
                             }
                         }
@@ -183,7 +190,20 @@ angular.module('matrixService', [])
                             deferred.resolve(response);
                         }
                         else if (response.data.next) {
-                            return doRegisterLogin(path, response.data.next, sessionId, user_name, password, threepidCreds).then(
+                            var nextType = response.data.next;
+                            if (response.data.next instanceof Array) {
+                                for (var i=0; i<response.data.next.length; i++) {
+                                    if (useThreePidFlow && response.data.next[i] == "m.login.email.identity") {
+                                        nextType = response.data.next[i];
+                                        break;
+                                    }
+                                    else if (!useThreePidFlow && response.data.next[i] != "m.login.email.identity") {
+                                        nextType = response.data.next[i];
+                                        break;
+                                    }
+                                }
+                            }
+                            return doRegisterLogin(path, nextType, sessionId, user_name, password, threepidCreds).then(
                                 loginResponseFunc,
                                 function(err) {
                                     deferred.reject(err);