diff options
author | Munyoki Kilyungi | 2025-05-06 09:16:27 +0300 |
---|---|---|
committer | Munyoki Kilyungi | 2025-05-06 09:20:52 +0300 |
commit | 5cad25d44bc789e3f7de417cbe3b40b5073d2294 (patch) | |
tree | 9790631afba62b38ac85b075d0fab8780c70bcff /gn_auth/auth/requests.py | |
parent | 55e9e13422a7a5ee4650597e86ac8629de83c383 (diff) | |
download | gn-auth-5cad25d44bc789e3f7de417cbe3b40b5073d2294.tar.gz |
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'gn_auth/auth/requests.py')
-rw-r--r-- | gn_auth/auth/requests.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gn_auth/auth/requests.py b/gn_auth/auth/requests.py index e876641..cd939dd 100644 --- a/gn_auth/auth/requests.py +++ b/gn_auth/auth/requests.py @@ -5,6 +5,10 @@ from flask import request def request_json() -> dict: """Retrieve the JSON sent in a request.""" try: - return request.json + json_data = request.json + # KLUDGE: We have this check here since request.json has the + # type Any | None; see: + # <https://github.com/pallets/werkzeug/blob/7868bef5d978093a8baa0784464ebe5d775ae92a/src/werkzeug/wrappers/request.py#L545> + return json_data if isinstance(json_data, dict) else {} except werkzeug.exceptions.UnsupportedMediaType: return dict(request.form) or {} |