mirror of
https://github.com/Tivix/django-rest-auth.git
synced 2024-12-02 13:53:43 +03:00
Don't _require_ rest_framework_simplejwt
Rather than importing it at the top level (which breaks dj-rest-auth entirely if you aren't using JWTs and don't have the library installed), only do the import if the user has the relevant setting enabled.
This commit is contained in:
parent
40125b15c4
commit
40208ea0b6
|
@ -11,8 +11,20 @@ from rest_framework.generics import GenericAPIView, RetrieveUpdateAPIView
|
||||||
from rest_framework.permissions import AllowAny, IsAuthenticated
|
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
|
||||||
from rest_framework_simplejwt.exceptions import TokenError
|
|
||||||
from rest_framework_simplejwt.tokens import RefreshToken
|
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,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user