mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-07 10:20:57 +00:00
perf: Setting user attributes is invalid
This commit is contained in:
@@ -116,7 +116,6 @@ class DingTalkRequests(BaseRequest):
|
||||
|
||||
|
||||
class DingTalk:
|
||||
attributes = settings.DINGTALK_RENAME_ATTRIBUTES
|
||||
|
||||
def __init__(self, appid, appsecret, agentid, timeout=None):
|
||||
self._appid = appid or ''
|
||||
@@ -128,6 +127,10 @@ class DingTalk:
|
||||
timeout=timeout
|
||||
)
|
||||
|
||||
@property
|
||||
def attributes(self):
|
||||
return settings.DINGTALK_RENAME_ATTRIBUTES
|
||||
|
||||
def get_userinfo_bycode(self, code):
|
||||
body = {
|
||||
'clientId': self._appid,
|
||||
@@ -210,8 +213,8 @@ class DingTalk:
|
||||
return data
|
||||
|
||||
@staticmethod
|
||||
def default_user_detail(data):
|
||||
username = data['user_id']
|
||||
def default_user_detail(data, user_id):
|
||||
username = data.get('userid', user_id)
|
||||
name = data.get('name', username)
|
||||
email = data.get('email') or data.get('org_email')
|
||||
email = construct_user_email(username, email)
|
||||
@@ -227,6 +230,6 @@ class DingTalk:
|
||||
data = data['result']
|
||||
data['user_id'] = user_id
|
||||
info = flatten_dict(data)
|
||||
default_detail = self.default_user_detail(data)
|
||||
default_detail = self.default_user_detail(data, user_id)
|
||||
detail = map_attributes(default_detail, info, self.attributes)
|
||||
return detail
|
||||
|
Reference in New Issue
Block a user