summary refs log tree commit diff
path: root/synapse/rest
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2014-09-16 11:22:40 +0100
committerKegan Dougal <kegan@matrix.org>2014-09-16 11:22:40 +0100
commit5f30a69a9e617028c39ea3851b9a5de43d42a299 (patch)
treee6ee0b1e8c6760693a6f36ae1c24a37fb45a9601 /synapse/rest
parentMerge remote-tracking branch 'origin/develop' into webclient_data_centralisation (diff)
downloadsynapse-5f30a69a9e617028c39ea3851b9a5de43d42a299.tar.xz
Added PasswordResetRestServlet. Hit the IS to confirm the email/user. Need to send email.
Diffstat (limited to 'synapse/rest')
-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..7ab9cb51e8 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)
+    PasswordResetRestServlet(hs).register(http_server)