Organization admins can add any user as a member without their agreement

Open
#6,405 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python

Research direction

Start with contentcuration/viewsets/organization.py, especially OrganizationMemberSerializer and perform_create, then read contentcuration/viewsets/organization_migration.py around is_uncontested. Trace the invitation acceptance path and the regression tests for the two reproduced cases. Done means direct membership creation for another user is rejected, invitation acceptance preserves the invited role, and unaccepted editors require migration approval.

Written by the indexing model from the issue text.

Description

DEV: backend

Overview

POST /api/organization-members/ lets an organization admin add any user to the organization, with any role and status, without that user agreeing. Anyone can create an organization and become its admin, so any logged-in user can do this. The response returns the added user's email and name, and a channel editor added this way counts as agreeing to move their channel into the organization.

Complexity: Medium
Target branch: unstable

Context
  • OrganizationMemberSerializer limits organization to the requester's organizations, but user is a plain primary key field over all users. perform_create saves it as given.
  • The member viewset returns user_email, user_first_name and user_last_name.
  • Accepting an organization invitation finds the user with the same case-insensitive email lookup that #6409 fixes on hotfixes.
  • is_uncontested treats a channel migration as needing no administrator approval when every channel editor is an active admin or editor of the target organization.
  • Reproduced:
    • A user creates an organization, then sends {"organization": <their org>, "user": <any user id>, "status": "inactive"}. The response is 201 with that user's email and name. User ids are sequential integers.
    • Channel co-editor A creates an organization and adds co-editor B as an active editor. A's POST /api/channel/<id>/organization_migration/ then moves the channel without administrator approval, and A gains organization admin rights over it.
The Change
  • A user should join an organization only by accepting an organization invitation. Admins should not be able to create memberships for other users directly.
  • is_uncontested should count only memberships the user accepted.
Acceptance Criteria
General
  • POST /api/organization-members/ for a user other than the requester returns 4xx and creates no membership.
  • Accepting an organization invitation creates the membership with the invited role.
  • Migrating a channel into an organization that one of its editors hasn't joined by accepting an invitation requires administrator approval.
Testing
  • Regression tests cover both reproduced cases in Context.

AI usage

I scoped the audit and decided these findings get an unstable issue. Claude Code found and reproduced them and drafted this issue.

Dominant language
JavaScript
Stars
214
Forks
327
Avg merge
17h 5m
Merged PRs (30d)
25

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from learningequality/studio

All issues in learningequality/studio

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.