mirror of https://github.com/jumpserver/jumpserver
parent
001828fb2b
commit
c8eb7cccb1
|
@ -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()
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -3630,10 +3630,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
|
||||
|
|
|
@ -3709,11 +3709,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"
|
||||
|
|
|
@ -3659,11 +3659,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"
|
||||
|
|
|
@ -3661,11 +3661,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…
Reference in New Issue