From 0b211d33b2e9961f67e83304c45ccbe3c058bf2d Mon Sep 17 00:00:00 2001 From: ibuler Date: Mon, 11 Nov 2019 11:54:32 +0800 Subject: [PATCH] =?UTF-8?q?[Bugfix]=20=E4=BF=AE=E5=A4=8D=E6=B2=A1=E6=9C=89?= =?UTF-8?q?backend=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/authentication/mixins.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/authentication/mixins.py b/apps/authentication/mixins.py index 9be582c16..be7bfaf7d 100644 --- a/apps/authentication/mixins.py +++ b/apps/authentication/mixins.py @@ -30,6 +30,7 @@ class AuthMixin: user = get_object_or_none(User, pk=user_id) if not user: raise errors.SessionEmptyError() + user.backend = self.request.session.get("auth_backend") return user def get_request_ip(self): @@ -72,6 +73,8 @@ class AuthMixin: clean_failed_count(username, ip) request.session['auth_password'] = 1 request.session['user_id'] = str(user.id) + auth_backend = getattr(user, 'backend', 'django.contrib.auth.backends.ModelBackend') + request.session['auth_backend'] = auth_backend return user def check_user_auth_if_need(self):