forked from MirrorHub/synapse
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
1 changed files with 11 additions and 2 deletions
|
@ -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],
|
||||
|
|
Loading…
Reference in a new issue