0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-12-16 16:13:51 +01:00

Make captcha work again with the new registration logic.

This commit is contained in:
Kegan Dougal 2014-09-15 14:52:39 +01:00
parent d821755b49
commit 04fbda46dd
2 changed files with 22 additions and 1 deletions

View file

@ -133,6 +133,7 @@ class RegisterRestServlet(RestServlet):
logger.debug("Removing session %s", session) logger.debug("Removing session %s", session)
self.sessions.pop(session["id"]) self.sessions.pop(session["id"])
@defer.inlineCallbacks
def _do_recaptcha(self, request, register_json, session): def _do_recaptcha(self, request, register_json, session):
if not self.hs.config.enable_registration_captcha: if not self.hs.config.enable_registration_captcha:
raise SynapseError(400, "Captcha not required.") raise SynapseError(400, "Captcha not required.")

View file

@ -154,6 +154,13 @@ angular.module('matrixService', [])
} }
if (!useCaptcha && regType == "m.login.recaptcha") { if (!useCaptcha && regType == "m.login.recaptcha") {
console.error("Web client setup to not use captcha, but HS demands a captcha."); 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); deferred.resolve(response);
} }
else if (response.data.next) { 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, loginResponseFunc,
function(err) { function(err) {
deferred.reject(err); deferred.reject(err);