Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception Handling Causes 500 Response in LogoutView for Blacklisted, Invalid, or Expired Tokens #657

Open
mustafaulker opened this issue Sep 25, 2024 · 0 comments

Comments

@mustafaulker
Copy link

mustafaulker commented Sep 25, 2024

The LogoutView is returning a 500 error when handling blacklisted, invalid, or expired tokens. The issue arises because the exception handling block compares error messages as plain text without using gettext, which leads to a failure in non-english rest_framework_simplejwt.tokens.RefreshToken response.

if 'Token is blacklisted' in error.args or 'Token is invalid or expired' in error.args:
    response.data = {'detail': _(error.args[0])}
    response.status_code = status.HTTP_401_UNAUTHORIZED
else:
    response.data = {'detail': _('An error has occurred.')}
    response.status_code = status.HTTP_500_INTERNAL_SERVER_ERROR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant