From 76796f249dc95b06facf4f13ff3bb898c28b8f26 Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Thu, 17 Mar 2022 14:47:24 +0800 Subject: [PATCH] fix: user match (#7903) Co-authored-by: feng626 <1304903146@qq.com> --- apps/users/api/user.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/users/api/user.py b/apps/users/api/user.py index 092aef223..6d203a548 100644 --- a/apps/users/api/user.py +++ b/apps/users/api/user.py @@ -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 实现