Added a captcha config to the HS, to enable registration captcha checking and for the recaptcha private key.

This commit is contained in:
Kegan Dougal 2014-09-05 17:58:06 -07:00
parent c80f739461
commit 0b9e1e7b56
5 changed files with 44 additions and 3 deletions

View file

@ -16,7 +16,7 @@
"""This module contains REST servlets to do with registration: /register"""
from twisted.internet import defer
from synapse.api.errors import SynapseError
from synapse.api.errors import SynapseError, Codes
from base import RestServlet, client_path_pattern
import json
@ -50,6 +50,10 @@ class RegisterRestServlet(RestServlet):
threepidCreds = None
if 'threepidCreds' in register_json:
threepidCreds = register_json['threepidCreds']
if self.hs.config.enable_registration_captcha:
if not "challenge" in register_json or not "response" in register_json:
raise SynapseError(400, "Captcha response is required", errcode=Codes.NEEDS_CAPTCHA)
handler = self.handlers.registration_handler
(user_id, token) = yield handler.register(