From e2b7c902a5528c058592c1f01ade7f33e0fc0c50 Mon Sep 17 00:00:00 2001 From: xinwen Date: Mon, 22 Mar 2021 18:00:06 +0800 Subject: [PATCH] perf: delete_test_cookie --- apps/authentication/views/login.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/authentication/views/login.py b/apps/authentication/views/login.py index 6b0e799b2..9f628e6e8 100644 --- a/apps/authentication/views/login.py +++ b/apps/authentication/views/login.py @@ -55,6 +55,9 @@ class UserLoginView(mixins.AuthMixin, FormView): def form_valid(self, form): if not self.request.session.test_cookie_worked(): return HttpResponse(_("Please enable cookies and try again.")) + # https://docs.djangoproject.com/en/3.1/topics/http/sessions/#setting-test-cookies + self.request.session.delete_test_cookie() + try: self.check_user_auth(decrypt_passwd=True) except errors.AuthFailedError as e: