summary refs log tree commit diff
path: root/synapse/rest/login.py
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2014-09-17 18:27:47 +0100
committerPaul "LeoNerd" Evans <paul@matrix.org>2014-09-17 18:27:47 +0100
commit4571cf7baadf360e27e05a73142571da9f165d47 (patch)
treeed5850f285a35df2353b3562ed4bca1fd34d5324 /synapse/rest/login.py
parentRemark on remaining storage modules that still need unit tests (diff)
parentWEB-35: joins/parts should trigger desktop notifications (diff)
downloadsynapse-4571cf7baadf360e27e05a73142571da9f165d47.tar.xz
Merge branch 'develop' into test-sqlite-memory
Diffstat (limited to 'synapse/rest/login.py')
-rw-r--r--synapse/rest/login.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/synapse/rest/login.py b/synapse/rest/login.py
index ba49afcaa7..ad71f6c61d 100644
--- a/synapse/rest/login.py
+++ b/synapse/rest/login.py
@@ -73,6 +73,27 @@ class LoginFallbackRestServlet(RestServlet):
         return (200, {})
 
 
+class PasswordResetRestServlet(RestServlet):
+    PATTERN = client_path_pattern("/login/reset")
+
+    @defer.inlineCallbacks
+    def on_POST(self, request):
+        reset_info = _parse_json(request)
+        try:
+            email = reset_info["email"]
+            user_id = reset_info["user_id"]
+            handler = self.handlers.login_handler
+            yield handler.reset_password(user_id, email)
+            # purposefully give no feedback to avoid people hammering different
+            # combinations.
+            defer.returnValue((200, {}))
+        except KeyError:
+            raise SynapseError(
+                400,
+                "Missing keys. Requires 'email' and 'user_id'."
+            )
+
+
 def _parse_json(request):
     try:
         content = json.loads(request.content.read())
@@ -85,3 +106,4 @@ def _parse_json(request):
 
 def register_servlets(hs, http_server):
     LoginRestServlet(hs).register(http_server)
+    # TODO PasswordResetRestServlet(hs).register(http_server)