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

All calls to django-notifications-hq api rest, return empty notify list after JWT authentication #295

Closed
mauroesposito opened this issue Jul 24, 2020 · 3 comments

Comments

@mauroesposito
Copy link

It's a very strange situation: I'm using django-notifications-hq in my app, and if I call the notifications list from model user, I can see all user notifications:

image

But when I made a call by Api rest, well, I can see that the result is ever empty:

image

Debugging your def live_all_notification_list(request): I've noted that request.user is always an anonymous user.

Again: I've tryed to override your live_all_notification_list in mine main.view() (with a new url: path("v1/notifications/unread_list/", main_views.live_all_notification_list), to avoid potential urls conflicts) and I've discovered that the problem is the decorator @never_cache, indeed, updating this decorator with a more generic @api_view(["GET"]), all work like a charm:

image

And last but not least, I've updated in your library view the decorator as @api_view(["GET"]) instead of @never_cache, and this is the result:

image

All work fine, and the result is the same as view method override.

This may be a bug or exist a workaround to bypass this empasse?

Thank you guys for your work and for your help,
Mauro

@na0495
Copy link

na0495 commented Oct 18, 2022

you didn't include those changes in a pull request, to fix that issue when using drf & jwt ?

@KaizerJ
Copy link

KaizerJ commented Jun 1, 2023

With drf & token (knox token) authentication the initial behaviour happens too (have not tested the workaround)

@AlvaroLQueiroz
Copy link
Contributor

I believe this is not a bug on this lib, because the never_cache and the django-notifications don't change the request, If the user is arriving as Anonymous some code before this is making this change, probably some middleware.

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

No branches or pull requests

4 participants