Skip to content

fix: update get_user_list method to include user_id for workspace validation - #6586

Merged
wxg0103 merged 1 commit into
v2from
pr@v2@fix_get_user_list_add_workspace_validation
Aug 5, 2026
Merged

fix: update get_user_list method to include user_id for workspace validation#6586
wxg0103 merged 1 commit into
v2from
pr@v2@fix_get_user_list_add_workspace_validation

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

fix: update get_user_list method to include user_id for workspace validation

Copilot AI lite review requested due to automatic review settings August 5, 2026 02:33
@shaohuzhang1

Copy link
Copy Markdown
Contributor Author

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

@wxg0103
wxg0103 merged commit 7482d07 into v2 Aug 5, 2026
5 of 7 checks passed
@wxg0103
wxg0103 deleted the pr@v2@fix_get_user_list_add_workspace_validation branch August 5, 2026 02:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the workspace-scoped user listing endpoint to pass the current user’s ID into the serializer, enabling validation that the requesting user belongs to the target workspace before returning users.

Changes:

  • Updated WorkspaceUserListView to pass request.user.id into get_user_list.
  • Changed UserManageSerializer.get_user_list signature and added workspace-membership validation logic.
  • Minor refactors/formatting in apps/users/serializers/user.py (imports and a resource-mapping helper).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
apps/users/views/user.py Passes current user ID into the workspace user-list serializer call.
apps/users/serializers/user.py Adds user_id parameter to get_user_list and implements workspace membership validation logic.
Suppressed comments (2)

apps/users/serializers/user.py:566

  • get_user_list is currently granting admin-like access based on a hard-coded UUID and, in the EE/workspace-mapping branch, will return an empty list for users that are authorized by @has_permissions (e.g., RoleConstants.ADMIN) but not explicitly mapped to the workspace. Derive an is_admin flag from the actual user record/role and use it consistently to bypass the workspace-membership check, instead of relying on a literal UUID comparison inside the query logic.
    def get_user_list(self, user_id,workspace_id, nick_name):
        """
        获取用户列表
        :param workspace_id: 工作空间ID
        :return: 用户列表

apps/users/serializers/user.py:829

  • defaultdict is already imported at module scope, so re-importing it inside _get_resource_maps is redundant. Remove the local import to keep imports centralized and avoid unnecessary per-call work.
    from collections import defaultdict

    from application.models import Application, ApplicationFolder

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

from django.db import transaction
from django.db.models import Q, QuerySet
from django.utils import translation
from django.utils.translation import get_language, to_locale
Comment thread apps/users/views/user.py
def get(self, request: Request, workspace_id):
nick_name = request.query_params.get('nick_name', None)
return result.success(UserManageSerializer().get_user_list(workspace_id, nick_name))
return result.success(UserManageSerializer().get_user_list(str(request.user.id),workspace_id, nick_name))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants