fix: user match (#7903)

Co-authored-by: feng626 <1304903146@qq.com>
pull/7905/head
fit2bot 2022-03-17 14:47:24 +08:00 committed by GitHub
parent 55a63477ed
commit 76796f249d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -10,7 +10,7 @@ from rest_framework_bulk import BulkModelViewSet
from common.mixins import CommonApiMixin
from common.utils import get_logger
from common.mixins.api import SuggestionMixin
from orgs.utils import current_org
from orgs.utils import current_org, tmp_to_root_org
from rbac.models import Role, RoleBinding
from users.utils import LoginBlockUtil, MFABlockUtils
from .mixins import UserQuerysetMixin
@ -61,6 +61,11 @@ class UserViewSet(CommonApiMixin, UserQuerysetMixin, SuggestionMixin, BulkModelV
self.set_users_roles_for_cache(queryset)
return page
@action(methods=['get'], detail=False, url_path='suggestions')
def match(self, request, *args, **kwargs):
with tmp_to_root_org():
return super().match(request, *args, **kwargs)
@staticmethod
def set_users_roles_for_cache(queryset):
# Todo: 未来有机会用 SQL 实现