Remove dependency on allauth for logout on GET

This commit is contained in:
Maxim Kukhtenkov 2016-11-30 17:39:57 -08:00
parent 7fc875a4f5
commit 42ae22152a
2 changed files with 2 additions and 5 deletions

View File

@ -13,7 +13,7 @@ Basic
- /rest-auth/logout/ (POST, GET)
.. note:: (requires allauth) ``ACCOUNT_LOGOUT_ON_GET = True`` to allow logout using GET - this is the exact same conf from allauth. NOT recommended, see: http://django-allauth.readthedocs.io/en/latest/views.html#logout
.. note:: ``ACCOUNT_LOGOUT_ON_GET = True`` to allow logout using GET - this is the exact same configuration from allauth. NOT recommended, see: http://django-allauth.readthedocs.io/en/latest/views.html#logout
- token

View File

@ -12,9 +12,6 @@ from rest_framework.response import Response
from rest_framework.generics import GenericAPIView, RetrieveUpdateAPIView
from rest_framework.permissions import IsAuthenticated, AllowAny
if 'allauth' in settings.INSTALLED_APPS:
from allauth.account import app_settings as allauth_settings
from .app_settings import (
TokenSerializer, UserDetailsSerializer, LoginSerializer,
PasswordResetSerializer, PasswordResetConfirmSerializer,
@ -94,7 +91,7 @@ class LogoutView(APIView):
permission_classes = (AllowAny,)
def get(self, request, *args, **kwargs):
if 'allauth' in settings.INSTALLED_APPS and allauth_settings.LOGOUT_ON_GET:
if getattr(settings, 'ACCOUNT_LOGOUT_ON_GET', False):
response = self.logout(request)
else:
response = self.http_method_not_allowed(request, *args, **kwargs)