TOKEN_MODEL not compatible with JWT
See original GitHub issueThe TOKEN_MODEL variable was introduced in #189. This is used in utils.login_user and utils.logout_user.
The call tosettings.TOKEN_MODEL.objects.filter(user=request.user).delete()
doesn’t work with JWT, as it doesn’t define a model as tokens are stored client side, not in the database:
https://github.com/GetBlimp/django-rest-framework-jwt/blob/master/rest_framework_jwt/models.py
(The call to settings.TOKEN_MODEL.objects.get_or_create()
doesn’t affect JWT, as it’s never called when using JWT.)
For example, attempts to log out a user generates the following error:
File "/path/to/djoser/djoser/utils.py", line 23, in logout_user
settings.TOKEN_MODEL.objects.filter(user=request.user).delete()
AttributeError: type object 'Token' has no attribute 'objects'
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:8 (2 by maintainers)
Top Results From Across the Web
JSON Web Token Tutorial using AngularJS & Laravel - Toptal
Token based/JWT authentication is stateless, so there is no need to store user information in the session. This gives us the ability to...
Read more >'System.IdentityModel.Tokens.Jwt 5.1.4' is not compatible with ...
I spoke too soon, ran the site up in VS, Could not load file or assembly 'Autofac' or one of its dependencies. The...
Read more >Implement JWT In .NET Core API - C# Corner
In this article, you will learn how to implement JWT Authentication in ... will contain definitions for Authentication and TokenModel Model.
Read more >RFC 7519: JSON Web Token (JWT)
Unsecured JWT A JWT whose claims are not integrity protected or encrypted. ... "JWT" always be spelled using uppercase characters for compatibility with ......
Read more >JSON Web Token (JWT) RFC 7519 - IETF Datatracker
Unsecured JWT A JWT whose claims are not integrity protected or encrypted. ... "JWT" always be spelled using uppercase characters for compatibility with ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I just experienced the same problem when trying to delete currently logged user. Sending
DELETE
request to/users/me/
produces this error:I solved it by setting the
TOKEN_MODEL
toNone
as described here https://djoser.readthedocs.io/en/latest/settings.html#token-model+1