mirror of
https://mau.dev/maunium/synapse.git
synced 2024-09-02 15:41:57 +00:00
Merge pull request #608 from gergelypolonkai/syn-638
Add error codes for malformed/bad JSON in /login
This commit is contained in:
commit
9329cd5f13
@ -404,10 +404,12 @@ def _parse_json(request):
|
|||||||
try:
|
try:
|
||||||
content = json.loads(request.content.read())
|
content = json.loads(request.content.read())
|
||||||
if type(content) != dict:
|
if type(content) != dict:
|
||||||
raise SynapseError(400, "Content must be a JSON object.")
|
raise SynapseError(
|
||||||
|
400, "Content must be a JSON object.", errcode=Codes.BAD_JSON
|
||||||
|
)
|
||||||
return content
|
return content
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise SynapseError(400, "Content not JSON.")
|
raise SynapseError(400, "Content not JSON.", errcode=Codes.NOT_JSON)
|
||||||
|
|
||||||
|
|
||||||
def register_servlets(hs, http_server):
|
def register_servlets(hs, http_server):
|
||||||
|
Loading…
Reference in New Issue
Block a user