mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-18 16:39:28 +00:00
perf: 企业微信、钉钉、飞书本地没有用户即创建
This commit is contained in:
committed by
Jiangjie.Bai
parent
3f1858a105
commit
185f33c3e0
@@ -25,11 +25,9 @@ class BaseLoginCallbackView(AuthMixin, FlashMessageMixin, View):
|
||||
client_auth_params = {}
|
||||
user_type = ''
|
||||
auth_backend = None
|
||||
create_user_if_not_exist_setting = ''
|
||||
# 提示信息
|
||||
msg_client_err = _('Error')
|
||||
msg_user_not_bound_err = _('Error')
|
||||
msg_user_need_bound_warning = _('Error')
|
||||
msg_not_found_user_from_client_err = _('Error')
|
||||
|
||||
def verify_state(self):
|
||||
@@ -49,11 +47,6 @@ class BaseLoginCallbackView(AuthMixin, FlashMessageMixin, View):
|
||||
|
||||
def create_user_if_not_exist(self, user_id, **kwargs):
|
||||
user = None
|
||||
if not getattr(settings, self.create_user_if_not_exist_setting):
|
||||
title = self.msg_client_err
|
||||
msg = self.msg_user_need_bound_warning
|
||||
return user, (title, msg)
|
||||
|
||||
user_attr = self.client.get_user_detail(user_id, **kwargs)
|
||||
try:
|
||||
user, create = User.objects.get_or_create(
|
||||
|
@@ -205,11 +205,9 @@ class DingTalkQRLoginCallbackView(DingTalkQRMixin, BaseLoginCallbackView):
|
||||
}
|
||||
user_type = 'dingtalk'
|
||||
auth_backend = 'AUTH_BACKEND_DINGTALK'
|
||||
create_user_if_not_exist_setting = 'DINGTALK_CREATE_USER_IF_NOT_EXIST'
|
||||
|
||||
msg_client_err = _('DingTalk Error')
|
||||
msg_user_not_bound_err = _('DingTalk is not bound')
|
||||
msg_user_need_bound_warning = _('Please login with a password and then bind the DingTalk')
|
||||
msg_not_found_user_from_client_err = _('Failed to get user from DingTalk')
|
||||
|
||||
|
||||
|
@@ -162,10 +162,8 @@ class FeiShuQRLoginCallbackView(FeiShuQRMixin, BaseLoginCallbackView):
|
||||
client_auth_params = {'app_id': 'FEISHU_APP_ID', 'app_secret': 'FEISHU_APP_SECRET'}
|
||||
user_type = 'feishu'
|
||||
auth_backend = 'AUTH_BACKEND_FEISHU'
|
||||
create_user_if_not_exist_setting = 'FEISHU_CREATE_USER_IF_NOT_EXIST'
|
||||
|
||||
msg_client_err = _('FeiShu Error')
|
||||
msg_user_not_bound_err = _('FeiShu is not bound')
|
||||
msg_user_need_bound_warning = _('Please login with a password and then bind the FeiShu')
|
||||
msg_not_found_user_from_client_err = _('Failed to get user from FeiShu')
|
||||
|
||||
|
@@ -197,11 +197,9 @@ class WeComQRLoginCallbackView(WeComQRMixin, BaseLoginCallbackView):
|
||||
client_auth_params = {'corpid': 'WECOM_CORPID', 'corpsecret': 'WECOM_SECRET', 'agentid': 'WECOM_AGENTID'}
|
||||
user_type = 'wecom'
|
||||
auth_backend = 'AUTH_BACKEND_WECOM'
|
||||
create_user_if_not_exist_setting = 'WECOM_CREATE_USER_IF_NOT_EXIST'
|
||||
|
||||
msg_client_err = _('WeCom Error')
|
||||
msg_user_not_bound_err = _('WeCom is not bound')
|
||||
msg_user_need_bound_warning = _('Please login with a password and then bind the WeCom')
|
||||
msg_not_found_user_from_client_err = _('Failed to get user from WeCom')
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user