mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2025-01-03 04:30:50 -05:00
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.
This commit is contained in:
parent
fbd3866bc6
commit
9009143fb9
@ -17,7 +17,7 @@ import logging
|
|||||||
|
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
|
||||||
from synapse.api import constants
|
from synapse.api import constants, errors
|
||||||
from synapse.http import servlet
|
from synapse.http import servlet
|
||||||
from ._base import client_v2_patterns
|
from ._base import client_v2_patterns
|
||||||
|
|
||||||
@ -72,8 +72,17 @@ class DeviceRestServlet(servlet.RestServlet):
|
|||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def on_DELETE(self, request, device_id):
|
def on_DELETE(self, request, device_id):
|
||||||
|
try:
|
||||||
body = servlet.parse_json_object_from_request(request)
|
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([
|
authed, result, params, _ = yield self.auth_handler.check_auth([
|
||||||
[constants.LoginType.PASSWORD],
|
[constants.LoginType.PASSWORD],
|
||||||
], body, self.hs.get_ip_from_request(request))
|
], body, self.hs.get_ip_from_request(request))
|
||||||
|
Loading…
Reference in New Issue
Block a user