mirror of
https://github.com/Tivix/django-rest-auth.git
synced 2024-12-02 13:53:43 +03:00
Move import inside response method
This is not idiomatic, but I don't see another neat way to move it out of the top level and still handle testing / other situations where the settings are modified on-the-fly.
This commit is contained in:
parent
40208ea0b6
commit
506912f832
|
@ -12,20 +12,6 @@ from rest_framework.permissions import AllowAny, IsAuthenticated
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
|
|
||||||
if getattr(settings, 'REST_USE_JWT'):
|
|
||||||
from rest_framework_simplejwt.exceptions import TokenError
|
|
||||||
from rest_framework_simplejwt.tokens import RefreshToken
|
|
||||||
else:
|
|
||||||
# NOTE: these are not actually used except if `REST_USE_JWT` is True, but
|
|
||||||
# ensuring they're defined anyway in case
|
|
||||||
|
|
||||||
class TokenError(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
class RefreshToken:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
from .app_settings import (JWTSerializer, LoginSerializer,
|
from .app_settings import (JWTSerializer, LoginSerializer,
|
||||||
PasswordChangeSerializer,
|
PasswordChangeSerializer,
|
||||||
PasswordResetConfirmSerializer,
|
PasswordResetConfirmSerializer,
|
||||||
|
@ -154,6 +140,13 @@ class LogoutView(APIView):
|
||||||
status=status.HTTP_200_OK)
|
status=status.HTTP_200_OK)
|
||||||
|
|
||||||
if getattr(settings, 'REST_USE_JWT', False):
|
if getattr(settings, 'REST_USE_JWT', False):
|
||||||
|
# NOTE: this import occurs here rather than at the top level
|
||||||
|
# because JWT support is optional, and if `REST_USE_JWT` isn't
|
||||||
|
# True we shouldn't need the dependency
|
||||||
|
from rest_framework_simplejwt.exceptions import TokenError
|
||||||
|
from rest_framework_simplejwt.tokens import RefreshToken
|
||||||
|
|
||||||
|
|
||||||
cookie_name = getattr(settings, 'JWT_AUTH_COOKIE', None)
|
cookie_name = getattr(settings, 'JWT_AUTH_COOKIE', None)
|
||||||
if cookie_name:
|
if cookie_name:
|
||||||
response.delete_cookie(cookie_name)
|
response.delete_cookie(cookie_name)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user