Skip to content

Commit

Permalink
solution for issue jazzband#148
Browse files Browse the repository at this point in the history
  • Loading branch information
taiphuong committed Aug 15, 2019
1 parent 6eb9f6d commit cdae6d5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions rest_framework_simplejwt/authentication.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.utils.translation import ugettext_lazy as _
from rest_framework import HTTP_HEADER_ENCODING, authentication

from .exceptions import AuthenticationFailed, InvalidToken, TokenError
from .exceptions import AuthenticationFailed, InvalidToken, TokenError, NotAuthenticated
from .models import TokenUser
from .settings import api_settings
from .state import User
Expand All @@ -27,11 +27,11 @@ class JWTAuthentication(authentication.BaseAuthentication):
def authenticate(self, request):
header = self.get_header(request)
if header is None:
return None
raise NotAuthenticated()

raw_token = self.get_raw_token(header)
if raw_token is None:
return None
raise NotAuthenticated()

validated_token = self.get_validated_token(raw_token)

Expand Down
4 changes: 4 additions & 0 deletions rest_framework_simplejwt/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ class InvalidToken(AuthenticationFailed):
status_code = status.HTTP_401_UNAUTHORIZED
default_detail = _('Token is invalid or expired')
default_code = 'token_not_valid'


class NotAuthenticated(exceptions.NotAuthenticated):
pass

0 comments on commit cdae6d5

Please sign in to comment.