perf: 修改主题 (#8569)

* perf: 优化登录 backend

* perf: 修改主题

Co-authored-by: ibuler <ibuler@qq.com>
pull/8571/head
fit2bot 2 years ago committed by GitHub
parent f3cf071362
commit c7c0374c78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -443,13 +443,15 @@ class AuthMixin(CommonMixin, AuthPreCheckMixin, AuthACLMixin, MFAMixin, AuthPost
LoginIpBlockUtil(ip).clean_block_if_need() LoginIpBlockUtil(ip).clean_block_if_need()
return user return user
def mark_password_ok(self, user, auto_login=False): def mark_password_ok(self, user, auto_login=False, auth_backend=None):
request = self.request request = self.request
request.session['auth_password'] = 1 request.session['auth_password'] = 1
request.session['auth_password_expired_at'] = time.time() + settings.AUTH_EXPIRED_SECONDS request.session['auth_password_expired_at'] = time.time() + settings.AUTH_EXPIRED_SECONDS
request.session['user_id'] = str(user.id) request.session['user_id'] = str(user.id)
request.session['auto_login'] = auto_login request.session['auto_login'] = auto_login
request.session['auth_backend'] = getattr(user, 'backend', settings.AUTH_BACKEND_MODEL) if not auth_backend:
auth_backend = getattr(user, 'backend', settings.AUTH_BACKEND_MODEL)
request.session['auth_backend'] = auth_backend
def check_oauth2_auth(self, user: User, auth_backend): def check_oauth2_auth(self, user: User, auth_backend):
ip = self.get_request_ip() ip = self.get_request_ip()
@ -469,7 +471,7 @@ class AuthMixin(CommonMixin, AuthPreCheckMixin, AuthACLMixin, MFAMixin, AuthPost
LoginIpBlockUtil(ip).clean_block_if_need() LoginIpBlockUtil(ip).clean_block_if_need()
MFABlockUtils(user.username, ip).clean_failed_count() MFABlockUtils(user.username, ip).clean_failed_count()
self.mark_password_ok(user, False) self.mark_password_ok(user, False, auth_backend)
return user return user
def get_user_or_auth(self, valid_data): def get_user_or_auth(self, valid_data):

@ -300,5 +300,4 @@ class WeComOAuthLoginCallbackView(AuthMixin, WeComOAuthMixin, View):
msg = e.msg msg = e.msg
response = self.get_failed_response(login_url, title=msg, msg=msg) response = self.get_failed_response(login_url, title=msg, msg=msg)
return response return response
return self.redirect_to_guard_view() return self.redirect_to_guard_view()

@ -22,8 +22,8 @@
</style> </style>
<script> <script>
const theme = "{{ INTERFACE.theme }}"; const themeInfo = {{ INTERFACE.theme_info | safe }};
if (theme && theme.colors && theme.colors['--color-primary']) { if (themeInfo && themeInfo.colors && themeInfo.colors['--color-primary']) {
document.documentElement.style.setProperty('--primary-color', theme.colors['--color-primary']); document.documentElement.style.setProperty('--primary-color', themeInfo.colors['--color-primary']);
} }
</script> </script>

Loading…
Cancel
Save