[Bugfix] 修复没有backend的问题

pull/3428/head
ibuler 2019-11-11 11:54:32 +08:00
parent 74f22274b4
commit 0b211d33b2
1 changed files with 3 additions and 0 deletions

View File

@ -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):