Skip to content

Commit

Permalink
Verify should check if token_blacklist installed (#450)
Browse files Browse the repository at this point in the history
* Verify should check if token_blacklist installed

* Add missing import
  • Loading branch information
Andrew-Chen-Wang committed Oct 31, 2021
1 parent 4b962cc commit e5baf6a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion rest_framework_simplejwt/serializers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.conf import settings
from django.contrib.auth import authenticate, get_user_model
from django.contrib.auth.models import update_last_login
from django.utils.translation import gettext_lazy as _
Expand Down Expand Up @@ -147,7 +148,10 @@ class TokenVerifySerializer(serializers.Serializer):
def validate(self, attrs):
token = UntypedToken(attrs['token'])

if api_settings.BLACKLIST_AFTER_ROTATION:
if (
api_settings.BLACKLIST_AFTER_ROTATION
and 'rest_framework_simplejwt.token_blacklist' in settings.INSTALLED_APPS
):
jti = token.get(api_settings.JTI_CLAIM)
if BlacklistedToken.objects.filter(token__jti=jti).exists():
raise ValidationError("Token is blacklisted")
Expand Down

0 comments on commit e5baf6a

Please sign in to comment.