Browse Source

perf: Modify error message for desktop client login (#13763)

* perf: Modify error message for desktop client login

* perf: Update Dockerfile with new base image tag

---------

Co-authored-by: wangruidong <940853815@qq.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
pull/13803/head
fit2bot 4 months ago committed by GitHub
parent
commit
03a66fd563
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      Dockerfile
  2. 8
      apps/authentication/views/base.py
  3. 10
      apps/authentication/views/dingtalk.py
  4. 10
      apps/authentication/views/feishu.py
  5. 10
      apps/authentication/views/mixins.py
  6. 10
      apps/authentication/views/slack.py
  7. 10
      apps/authentication/views/wecom.py
  8. 6
      apps/i18n/core/en/LC_MESSAGES/django.po
  9. 11
      apps/i18n/core/ja/LC_MESSAGES/django.po
  10. 9
      apps/i18n/core/zh/LC_MESSAGES/django.po
  11. 9
      apps/i18n/core/zh_Hant/LC_MESSAGES/django.po

2
Dockerfile

@ -1,4 +1,4 @@
FROM jumpserver/core-base:20240722_031104 AS stage-build
FROM jumpserver/core-base:20240724_024214 AS stage-build
ARG VERSION

8
apps/authentication/views/base.py

@ -151,11 +151,9 @@ class BaseBindCallbackView(FlashMessageMixin, IMClientMixin, View):
setattr(user, f'{self.auth_type}_id', auth_user_id)
user.save()
except IntegrityError as e:
if e.args[0] == 1062:
msg = _('The %s is already bound to another user') % self.auth_type_label
response = self.get_failed_response(redirect_url, msg, msg)
return response
raise e
msg = _('The %s is already bound to another user') % self.auth_type_label
response = self.get_failed_response(redirect_url, msg, msg)
return response
ip = get_request_ip(request)
OAuthBindMessage(user, ip, self.auth_type_label, auth_user_id).publish_async()

10
apps/authentication/views/dingtalk.py

@ -47,15 +47,7 @@ class DingTalkBaseMixin(UserConfirmRequiredExceptionMixin, PermissionsMixin, Fla
)
def verify_state(self):
state = self.request.GET.get('state')
session_state = self.request.session.get(DINGTALK_STATE_SESSION_KEY)
if state != session_state:
return False
return True
def get_verify_state_failed_response(self, redirect_uri):
msg = _("The system configuration is incorrect. Please contact your administrator")
return self.get_failed_response(redirect_uri, msg, msg)
return self.verify_state_with_session_key(DINGTALK_STATE_SESSION_KEY)
def get_already_bound_response(self, redirect_url):
msg = _('DingTalk is already bound')

10
apps/authentication/views/feishu.py

@ -58,15 +58,7 @@ class FeiShuQRMixin(UserConfirmRequiredExceptionMixin, PermissionsMixin, FlashMe
)
def verify_state(self):
state = self.request.GET.get('state')
session_state = self.request.session.get(self.state_session_key)
if state != session_state:
return False
return True
def get_verify_state_failed_response(self, redirect_uri):
msg = _("The system configuration is incorrect. Please contact your administrator")
return self.get_failed_response(redirect_uri, msg, msg)
return self.verify_state_with_session_key(self.state_session_key)
def get_qr_url(self, redirect_uri):
state = random_string(16)

10
apps/authentication/views/mixins.py

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
#
from django.utils.translation import gettext_lazy as _
from common.utils import FlashMessageUtil
@ -32,3 +33,12 @@ class FlashMessageMixin:
def get_failed_response(self, redirect_url, title, msg, interval=10):
return self.get_response(redirect_url, title, msg, 'error', interval)
def get_verify_state_failed_response(self, redirect_uri):
msg = _(
"For your safety, automatic redirection login is not supported on the client."
" If you need to open it in the client, please log in again")
return self.get_failed_response(redirect_uri, msg, msg)
def verify_state_with_session_key(self, session_key):
return self.request.GET.get('state') == self.request.session.get(session_key)

10
apps/authentication/views/slack.py

@ -37,15 +37,7 @@ class SlackMixin(UserConfirmRequiredExceptionMixin, PermissionsMixin, FlashMessa
)
def verify_state(self):
state = self.request.GET.get('state')
session_state = self.request.session.get(SLACK_STATE_SESSION_KEY)
if state != session_state:
return False
return True
def get_verify_state_failed_response(self, redirect_uri):
msg = _("The system configuration is incorrect. Please contact your administrator")
return self.get_failed_response(redirect_uri, msg, msg)
return self.verify_state_with_session_key(SLACK_STATE_SESSION_KEY)
def get_qr_url(self, redirect_uri):
state = random_string(16)

10
apps/authentication/views/wecom.py

@ -45,15 +45,7 @@ class WeComBaseMixin(UserConfirmRequiredExceptionMixin, PermissionsMixin, FlashM
)
def verify_state(self):
state = self.request.GET.get('state')
session_state = self.request.session.get(WECOM_STATE_SESSION_KEY)
if state != session_state:
return False
return True
def get_verify_state_failed_response(self, redirect_uri):
msg = _("The system configuration is incorrect. Please contact your administrator")
return self.get_failed_response(redirect_uri, msg, msg)
return self.verify_state_with_session_key(WECOM_STATE_SESSION_KEY)
def get_already_bound_response(self, redirect_url):
msg = _('WeCom is already bound')

6
apps/i18n/core/en/LC_MESSAGES/django.po

@ -3641,10 +3641,10 @@ msgstr ""
msgid "DingTalk Error"
msgstr ""
#: authentication/views/dingtalk.py:57 authentication/views/feishu.py:68
#: authentication/views/slack.py:47 authentication/views/wecom.py:55
#: authentication/views/mixins.py:39
msgid ""
"The system configuration is incorrect. Please contact your administrator"
"For your safety, automatic redirection login is not supported on the client. "
"If you need to open it in the client, please log in again"
msgstr ""
#: authentication/views/dingtalk.py:61

11
apps/i18n/core/ja/LC_MESSAGES/django.po

@ -3720,11 +3720,14 @@ msgstr "DingTalkエラー、システム管理者に連絡してください"
msgid "DingTalk Error"
msgstr "DingTalkエラー"
#: authentication/views/dingtalk.py:57 authentication/views/feishu.py:68
#: authentication/views/slack.py:47 authentication/views/wecom.py:55
#: authentication/views/mixins.py:39
msgid ""
"The system configuration is incorrect. Please contact your administrator"
msgstr "システム設定が正しくありません。管理者に連絡してください"
"For your safety, automatic redirection login is not supported on the client. "
"If you need to open it in the client, please log in again"
msgstr ""
"安全のため、クライアントでの自動リダイレクトログインはサポートされていませ"
"ん。クライアントで開く必要がある場合は、再度ログインしてください"
#: authentication/views/dingtalk.py:61
msgid "DingTalk is already bound"

9
apps/i18n/core/zh/LC_MESSAGES/django.po

@ -3670,11 +3670,12 @@ msgstr "钉钉错误,请联系系统管理员"
msgid "DingTalk Error"
msgstr "钉钉错误"
#: authentication/views/dingtalk.py:57 authentication/views/feishu.py:68
#: authentication/views/slack.py:47 authentication/views/wecom.py:55
#: authentication/views/mixins.py:39
msgid ""
"The system configuration is incorrect. Please contact your administrator"
msgstr "企业配置错误,请联系系统管理员"
"For your safety, automatic redirection login is not supported on the client. "
"If you need to open it in the client, please log in again"
msgstr ""
"为了您的安全,客户端不支持自动跳转登录。如果需要在客户端中打开,请重新登录"
#: authentication/views/dingtalk.py:61
msgid "DingTalk is already bound"

9
apps/i18n/core/zh_Hant/LC_MESSAGES/django.po

@ -3672,11 +3672,12 @@ msgstr "釘釘錯誤,請聯絡系統管理員"
msgid "DingTalk Error"
msgstr "釘釘錯誤"
#: authentication/views/dingtalk.py:57 authentication/views/feishu.py:68
#: authentication/views/slack.py:47 authentication/views/wecom.py:55
#: authentication/views/mixins.py:39
msgid ""
"The system configuration is incorrect. Please contact your administrator"
msgstr "企業配置錯誤,請聯絡系統管理員"
"For your safety, automatic redirection login is not supported on the client. "
"If you need to open it in the client, please log in again"
msgstr ""
"為了您的安全,客戶端不支持自動跳轉登錄。如果需要在客戶端中打開,請重新登錄"
#: authentication/views/dingtalk.py:61
msgid "DingTalk is already bound"

Loading…
Cancel
Save