Browse Source

fix: 修复获取系统用户认证信息API

pull/7390/head
Michael Bai 3 years ago committed by 老广
parent
commit
4cbf6dd5e6
  1. 3
      apps/assets/api/system_user.py
  2. 11
      apps/assets/models/user.py
  3. 2
      apps/authentication/api/connection_token.py

3
apps/assets/api/system_user.py

@ -138,7 +138,8 @@ class SystemUserAppAuthInfoApi(generics.RetrieveAPIView):
instance = super().get_object()
app_id = self.kwargs.get('app_id')
user_id = self.request.query_params.get("user_id")
instance.load_app_more_auth(app_id, user_id)
username = self.request.query_params.get("username")
instance.load_app_more_auth(app_id, username, user_id)
return instance

11
apps/assets/models/user.py

@ -129,12 +129,21 @@ class AuthMixin:
if password:
self.password = password
def load_app_more_auth(self, app_id=None, user_id=None):
def load_app_more_auth(self, app_id=None, username=None, user_id=None):
self._clean_auth_info_if_manual_login_mode()
# 加载临时认证信息
if self.login_mode == self.LOGIN_MANUAL:
self._load_tmp_auth_if_has(app_id, user_id)
return
# 更新用户名
from users.models import User
user = get_object_or_none(User, pk=user_id) if user_id else None
if self.username_same_with_user:
if user and not username:
_username = user.username
else:
_username = username
self.username = _username
def load_asset_special_auth(self, asset, username=''):
"""

2
apps/authentication/api/connection_token.py

@ -294,7 +294,7 @@ class SecretDetailMixin:
data.update(asset_detail)
else:
app_detail = self._get_application_secret_detail(app)
system_user.load_app_more_auth(app.id, user.id)
system_user.load_app_more_auth(app.id, user.username, user.id)
data['type'] = 'application'
data.update(app_detail)

Loading…
Cancel
Save