From 42ae22152adeb664c9df2d8b444454e486433bd3 Mon Sep 17 00:00:00 2001 From: Maxim Kukhtenkov Date: Wed, 30 Nov 2016 17:39:57 -0800 Subject: [PATCH] Remove dependency on allauth for logout on GET --- docs/api_endpoints.rst | 2 +- rest_auth/views.py | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/docs/api_endpoints.rst b/docs/api_endpoints.rst index af2cc85..28c5371 100644 --- a/docs/api_endpoints.rst +++ b/docs/api_endpoints.rst @@ -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 diff --git a/rest_auth/views.py b/rest_auth/views.py index 54ebee1..e487c31 100644 --- a/rest_auth/views.py +++ b/rest_auth/views.py @@ -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)