Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return json output instead of html when wrong token in Header Authorization #1247

Merged

Conversation

jerryfletcher21
Copy link
Contributor

What does this PR do?

Fixes #1246

In robosats/middleware.py return a JsonResponse instead of raising AuthenticationFailed Exception that is turned into the general html error by django.

rest_framework.response.Response should not be used in middleware, will return django.template.response.ContentNotRenderedError.

Checklist before merging

  • Install pre-commit and initialize it: pip install pre-commit, then pre-commit install. Pre-commit installs git hooks that automatically check the codebase. If pre-commit fails when you commit your changes, please fix the problems it points out.

Return a JsonResponse instead of raising AuthenticationFailed
Exception that is turned into the general html error by django.

rest_framework.response.Response should not be used in middleware,
will return django.template.response.ContentNotRenderedError.
@jerryfletcher21 jerryfletcher21 changed the title fix #1246 Return json output instead of html when wrong token in Header Authorization Apr 26, 2024
@Reckless-Satoshi
Copy link
Collaborator

Hey @jerryfletcher21 thank you very much for this PR. In fact, we should be using JsonResponse() on all API responses (not currently happening).

Please post a 15K Sats invoice with a long expiration time for a small DevFund tip.

@Reckless-Satoshi Reckless-Satoshi merged commit c3d1cd2 into RoboSats:main Apr 29, 2024
1 check passed
@jerryfletcher21
Copy link
Contributor Author

jerryfletcher21 commented Jun 18, 2024

Please post a 15K Sats invoice with a long expiration time for a small DevFund tip.

lnbc150u1pn8yxfhsp524awjx3pntzuzm2kax5te7mygc48k55g7k9672e3dml9su7qy9nqpp5q8prrwdt3yfrwtv4kpnu9esv02lexvzqhf5scc5r8203ca0hmu8sdqqxq9zf6sqcqzysrzjqdllz2m2fe9ukju5fdkjptcgehlkrv6xrswl7rgq4zrfws2d3yduwr8j0yqpv2sqqqqqqqlgqqqqp9sq2q9qxpqysgqkzryh86v5l03e6x8un4840g5595p2xp3hp0wv82ywyarlrmj9kphg7g8j5533hxcsgrx2sq5gu37glmjltfggn28w3253eyrae8yumspjqycmj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Html instead of json output returned when wrong token in Header Authorization
2 participants