summary refs log tree commit diff
path: root/synapse/rest/client/v2_alpha
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2016-10-12 18:47:28 +0100
committerRichard van der Hoff <richard@matrix.org>2016-10-12 18:47:28 +0100
commit9009143fb9774f583c19019aad0556934e6c6763 (patch)
tree97db9a4ba60ad1109851d6a918f9de40eb062079 /synapse/rest/client/v2_alpha
parentUser-interactive auth on delete device (diff)
downloadsynapse-9009143fb9774f583c19019aad0556934e6c6763.tar.xz
Handle delete device requests with no body
We should probably return a 401 rather than a 400 for existing clients that
don't know they have to do the UIA dance to delete a device.
Diffstat (limited to 'synapse/rest/client/v2_alpha')
-rw-r--r--synapse/rest/client/v2_alpha/devices.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/synapse/rest/client/v2_alpha/devices.py b/synapse/rest/client/v2_alpha/devices.py
index c0f94de72c..3ba0b0fc07 100644
--- a/synapse/rest/client/v2_alpha/devices.py
+++ b/synapse/rest/client/v2_alpha/devices.py
@@ -17,7 +17,7 @@ import logging
 
 from twisted.internet import defer
 
-from synapse.api import constants
+from synapse.api import constants, errors
 from synapse.http import servlet
 from ._base import client_v2_patterns
 
@@ -72,7 +72,16 @@ class DeviceRestServlet(servlet.RestServlet):
 
     @defer.inlineCallbacks
     def on_DELETE(self, request, device_id):
-        body = servlet.parse_json_object_from_request(request)
+        try:
+            body = servlet.parse_json_object_from_request(request)
+
+        except errors.SynapseError as e:
+            if e.errcode == errors.Codes.NOT_JSON:
+                # deal with older clients which didn't pass a JSON dict
+                # the same as those that pass an empty dict
+                body = {}
+            else:
+                raise
 
         authed, result, params, _ = yield self.auth_handler.check_auth([
             [constants.LoginType.PASSWORD],