Skip to content

Commit

Permalink
Handle null token on invalidation
Browse files Browse the repository at this point in the history
  • Loading branch information
pbgc committed Jul 28, 2020
1 parent 0ec7d6b commit b52c7f3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion jwt_auth/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def get_jwt_value(request):

def authenticate(self, request):
jwt_value = JSONWebTokenAuthMixin.get_jwt_value(request)
if is_token_blacklisted(jwt_value):
if jwt_value is not None and is_token_blacklisted(jwt_value):
raise exceptions.AuthenticationFailed(_('Invalid Token!'))
try:
self.payload = jwt_decode_handler(jwt_value)
Expand Down
3 changes: 2 additions & 1 deletion jwt_auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ class InvalidateJSONWebToken(View):
def post(self, request, *args, **kwargs):
try:
token = JSONWebTokenAuthMixin.get_jwt_value(request)
blacklist_token(token)
if token is not None:
blacklist_token(token)
except Exception as e:
print(e)
response = JsonResponse({})
Expand Down

0 comments on commit b52c7f3

Please sign in to comment.