Skip to content

Commit

Permalink
#541 Address test failures.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Routh committed Nov 19, 2023
1 parent bd5dda5 commit 01123a6
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions dj_rest_auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,20 +177,21 @@ def logout(self, request):

if 'rest_framework_simplejwt.token_blacklist' in settings.INSTALLED_APPS:
# add refresh token to blacklist
token: RefreshToken = RefreshToken(None)
if api_settings.JWT_AUTH_HTTPONLY:
try:
token = RefreshToken(request.COOKIES[api_settings.JWT_AUTH_REFRESH_COOKIE])
except KeyError:
response.data = {'detail': _('Refresh token was not included in cookie data.')}
response.status_code =status.HTTP_401_UNAUTHORIZED
else:
try:
token = RefreshToken(request.data['refresh'])
except KeyError:
response.data = {'detail': _('Refresh token was not included in request data.')}
response.status_code =status.HTTP_401_UNAUTHORIZED
try:
token: RefreshToken = RefreshToken(None)
if api_settings.JWT_AUTH_HTTPONLY:
try:
token = RefreshToken(request.COOKIES[api_settings.JWT_AUTH_REFRESH_COOKIE])
except KeyError:
response.data = {'detail': _('Refresh token was not included in cookie data.')}
response.status_code =status.HTTP_401_UNAUTHORIZED
else:
try:
token = RefreshToken(request.data['refresh'])
except KeyError:
response.data = {'detail': _('Refresh token was not included in request data.')}
response.status_code =status.HTTP_401_UNAUTHORIZED

token.blacklist()
except (TokenError, AttributeError, TypeError) as error:
if hasattr(error, 'args'):
Expand Down

0 comments on commit 01123a6

Please sign in to comment.