summary refs log tree commit diff
path: root/synapse/api/errors.py
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2014-09-05 19:18:23 -0700
committerKegan Dougal <kegan@matrix.org>2014-09-05 19:18:23 -0700
commit1829b55bb0d75d29475ac84eeb3e37cad8b334c7 (patch)
tree331df854248d9579fc2e4c91da09ab10423f910a /synapse/api/errors.py
parentAdded a captcha config to the HS, to enable registration captcha checking and... (diff)
downloadsynapse-1829b55bb0d75d29475ac84eeb3e37cad8b334c7.tar.xz
Captchas now work on registration. Missing x-forwarded-for config arg support. Missing reloading a new captcha on the web client / displaying a sensible error message.
Diffstat (limited to 'synapse/api/errors.py')
-rw-r--r--synapse/api/errors.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/synapse/api/errors.py b/synapse/api/errors.py
index 8e9dd2aba6..88175602c4 100644
--- a/synapse/api/errors.py
+++ b/synapse/api/errors.py
@@ -29,7 +29,8 @@ class Codes(object):
     NOT_FOUND = "M_NOT_FOUND"
     UNKNOWN_TOKEN = "M_UNKNOWN_TOKEN"
     LIMIT_EXCEEDED = "M_LIMIT_EXCEEDED"
-    NEEDS_CAPTCHA = "M_NEEDS_CAPTCHA"
+    CAPTCHA_NEEDED = "M_CAPTCHA_NEEDED"
+    CAPTCHA_INVALID = "M_CAPTCHA_INVALID"
 
 
 class CodeMessageException(Exception):
@@ -102,6 +103,19 @@ class StoreError(SynapseError):
     pass
 
 
+class InvalidCaptchaError(SynapseError):
+    def __init__(self, code=400, msg="Invalid captcha.", error_url=None,
+                 errcode=Codes.CAPTCHA_INVALID):
+        super(InvalidCaptchaError, self).__init__(code, msg, errcode)
+        self.error_url = error_url
+
+    def error_dict(self):
+        return cs_error(
+            self.msg,
+            self.errcode,
+            error_url=self.error_url,
+        )
+
 class LimitExceededError(SynapseError):
     """A client has sent too many requests and is being throttled.
     """