-
Notifications
You must be signed in to change notification settings - Fork 532
Add ability for organization admins to remove non-admin members via dashboard and API #7250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Co-authored-by: rishi-raj-jain <[email protected]>
Co-authored-by: rishi-raj-jain <[email protected]>
Co-authored-by: rishi-raj-jain <[email protected]>
Co-authored-by: rishi-raj-jain <[email protected]>
|
@copilot have you ensured that the removal permission is only with the admin? |
Currently, any organization member with write permissions ( The implementation prevents removing the organization admin (returns 403), but doesn't restrict removal to only admins. Should I change this so that only the organization admin can remove members? Or is the current behavior (any member with write permissions can remove non-admins) acceptable? |
Yes |
Co-authored-by: rishi-raj-jain <[email protected]>
Done. Changed the implementation so only organization admins can remove members. Backend changes:
Frontend changes:
Test updates:
|
Overview
This PR implements the ability for organization admins to remove non-admin members from organizations through both the API and the dashboard UI. Only the organization admin can perform member removals, and the admin themselves cannot be removed, ensuring that organizations always maintain at least one administrator.
Changes
Backend
New DELETE Endpoint
DELETE /v1/organizations/{id}/members/{user_id}endpointOrganizationsWriteauthentication (web_write or organizations_write scope)remove_member_safeservice method with proper validationEnhanced Member Schema
user_idfield toOrganizationMemberschema for member identificationis_adminboolean field to distinguish organization admins from regular membersUpdated Members List Endpoint
GET /v1/organizations/{id}/membersto populate theis_adminfieldError Handling
Frontend
UI Components
Confirmation Modal
RemoveMemberModalcomponent with clear warning messageUser Feedback
API Integration
useRemoveOrganizationMemberReact hookuseAuthhook to determine if current user is an adminTesting
Added comprehensive test coverage in
tests/organization/test_endpoints.py:All 41 organization endpoint tests pass successfully.
Screenshots
The UI now displays:
Notes
pnpm run generateinclients/packages/clientwhen the API server is running to update the generated types with the newuser_idandis_adminfields.This pull request was created as a result of the following prompt from Copilot chat.
Original prompt
This pull request was created as a result of the following prompt from Copilot chat.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.