perf: 企业微信、钉钉、飞书本地没有用户即创建

pull/10409/head
jiangweidong 2023-05-08 16:55:04 +08:00 committed by Jiangjie.Bai
parent 3f1858a105
commit 185f33c3e0
8 changed files with 0 additions and 25 deletions

View File

@ -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(

View File

@ -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')

View File

@ -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')

View File

@ -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')

View File

@ -365,21 +365,18 @@ class Config(dict):
'WECOM_CORPID': '',
'WECOM_AGENTID': '',
'WECOM_SECRET': '',
'WECOM_CREATE_USER_IF_NOT_EXIST': False,
# 钉钉
'AUTH_DINGTALK': False,
'DINGTALK_AGENTID': '',
'DINGTALK_APPKEY': '',
'DINGTALK_APPSECRET': '',
'DINGTALK_CREATE_USER_IF_NOT_EXIST': False,
# 飞书
'AUTH_FEISHU': False,
'FEISHU_APP_ID': '',
'FEISHU_APP_SECRET': '',
'FEISHU_VERSION': 'feishu',
'FEISHU_CREATE_USER_IF_NOT_EXIST': False,
'LOGIN_REDIRECT_TO_BACKEND': '', # 'OPENID / CAS / SAML2
'LOGIN_REDIRECT_MSG_ENABLED': True,

View File

@ -13,6 +13,3 @@ class DingTalkSettingSerializer(serializers.Serializer):
DINGTALK_APPKEY = serializers.CharField(max_length=256, required=True, label='AppKey')
DINGTALK_APPSECRET = EncryptedField(max_length=256, required=False, label='AppSecret')
AUTH_DINGTALK = serializers.BooleanField(default=False, label=_('Enable DingTalk Auth'))
DINGTALK_CREATE_USER_IF_NOT_EXIST = serializers.BooleanField(
default=False, label=_('Create user if not')
)

View File

@ -19,6 +19,3 @@ class FeiShuSettingSerializer(serializers.Serializer):
FEISHU_VERSION = serializers.ChoiceField(
choices=VERSION_CHOICES, default='feishu', label=_('Version')
)
FEISHU_CREATE_USER_IF_NOT_EXIST = serializers.BooleanField(
default=False, label=_('Create user if not')
)

View File

@ -13,6 +13,3 @@ class WeComSettingSerializer(serializers.Serializer):
WECOM_AGENTID = serializers.CharField(max_length=256, required=True, label='agentid')
WECOM_SECRET = EncryptedField(max_length=256, required=False, label='secret')
AUTH_WECOM = serializers.BooleanField(default=False, label=_('Enable WeCom Auth'))
WECOM_CREATE_USER_IF_NOT_EXIST = serializers.BooleanField(
default=False, label=_('Create user if not')
)