From 78f66c46e8992a6215ebbf808962e76b4cb1ae8f Mon Sep 17 00:00:00 2001 From: ibuler Date: Fri, 18 Aug 2023 16:59:07 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BF=AE=E6=94=B9=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/authentication/templates/authentication/login.html | 3 ++- apps/authentication/views/login.py | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/authentication/templates/authentication/login.html b/apps/authentication/templates/authentication/login.html index 7163573ba..67a627c92 100644 --- a/apps/authentication/templates/authentication/login.html +++ b/apps/authentication/templates/authentication/login.html @@ -235,7 +235,8 @@ {% if not origin_is_allowed %}
配置文件存在问题,无法完成登录,请联系管理员解决,或查看最新更新说明
- Configuration file has problems and cannot be logged in. Please contact the administrator + Configuration file has problems and cannot be logged in. Please contact the administrator
+ - {{ origin }} -
{% endif %}
diff --git a/apps/authentication/views/login.py b/apps/authentication/views/login.py index 15066c167..748d1e759 100644 --- a/apps/authentication/views/login.py +++ b/apps/authentication/views/login.py @@ -140,12 +140,13 @@ class UserLoginContextMixin: try: referer = urlparse(http_referer) except ValueError: - return False + return False, None allowed_domains = settings.ALLOWED_DOMAINS - return referer.netloc in allowed_domains + return referer.netloc in allowed_domains, referer.netloc def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) + origin_allowed, origin = self.origin_is_allowed() context.update({ 'demo_mode': os.environ.get("DEMO_MODE"), 'auth_methods': self.get_support_auth_methods(), @@ -153,7 +154,8 @@ class UserLoginContextMixin: 'current_lang': self.get_current_lang(), 'forgot_password_url': self.get_forgot_password_url(), 'extra_fields_count': self.get_extra_fields_count(context), - 'origin_is_allowed': self.origin_is_allowed(), + 'origin_is_allowed': origin_allowed, + 'origin': origin, **self.get_user_mfa_context(self.request.user) }) return context