Skip to content

Commit 7fc875a

Browse files
committed
Change handling for logout on GET
+ Make it require allauth + Add a note to docs that it’s not a recommended setting
1 parent 667e70c commit 7fc875a

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

docs/api_endpoints.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Basic
1313

1414
- /rest-auth/logout/ (POST, GET)
1515

16-
.. note:: ``ACCOUNT_LOGOUT_ON_GET = True`` to allow logout using GET (this is the exact same conf from allauth)
16+
.. 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
1717

1818
- token
1919

rest_auth/views.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,10 @@ class LogoutView(APIView):
9494
permission_classes = (AllowAny,)
9595

9696
def get(self, request, *args, **kwargs):
97-
try:
98-
if allauth_settings.LOGOUT_ON_GET:
99-
response = self.logout(request)
100-
else:
101-
response = self.http_method_not_allowed(request, *args, **kwargs)
102-
except Exception as exc:
103-
response = self.handle_exception(exc)
97+
if 'allauth' in settings.INSTALLED_APPS and allauth_settings.LOGOUT_ON_GET:
98+
response = self.logout(request)
99+
else:
100+
response = self.http_method_not_allowed(request, *args, **kwargs)
104101

105102
return self.finalize_response(request, response, *args, **kwargs)
106103

0 commit comments

Comments
 (0)