perf: 普通用户工单申请时,选择指定账号,提示无权限

pull/10110/head
jiangweidong 2023-03-30 16:06:30 +08:00 committed by Jiangjie.Bai
parent 0cd6667ede
commit 4c5e47cb99
1 changed files with 5 additions and 3 deletions

View File

@ -8,7 +8,7 @@ from accounts import serializers
from accounts.filters import AccountFilterSet from accounts.filters import AccountFilterSet
from accounts.models import Account from accounts.models import Account
from assets.models import Asset, Node from assets.models import Asset, Node
from common.permissions import UserConfirmation, ConfirmType from common.permissions import UserConfirmation, ConfirmType, IsValidUser
from common.views.mixins import RecordViewLogMixin from common.views.mixins import RecordViewLogMixin
from orgs.mixins.api import OrgBulkModelViewSet from orgs.mixins.api import OrgBulkModelViewSet
from rbac.permissions import RBACPermission from rbac.permissions import RBACPermission
@ -29,7 +29,6 @@ class AccountViewSet(OrgBulkModelViewSet):
rbac_perms = { rbac_perms = {
'partial_update': ['accounts.change_account'], 'partial_update': ['accounts.change_account'],
'su_from_accounts': 'accounts.view_account', 'su_from_accounts': 'accounts.view_account',
'username_suggestions': 'accounts.view_account',
'clear_secret': 'accounts.change_account', 'clear_secret': 'accounts.change_account',
} }
@ -50,7 +49,10 @@ class AccountViewSet(OrgBulkModelViewSet):
serializer = serializers.AccountSerializer(accounts, many=True) serializer = serializers.AccountSerializer(accounts, many=True)
return Response(data=serializer.data) return Response(data=serializer.data)
@action(methods=['get'], detail=False, url_path='username-suggestions') @action(
methods=['get'], detail=False, url_path='username-suggestions',
permission_classes=[IsValidUser]
)
def username_suggestions(self, request, *args, **kwargs): def username_suggestions(self, request, *args, **kwargs):
asset_ids = request.query_params.get('assets') asset_ids = request.query_params.get('assets')
node_keys = request.query_params.get('keys') node_keys = request.query_params.get('keys')