Skip to content

feat: org ownership transfer#760

Merged
nimish-ks merged 38 commits intomainfrom
feat--org-ownership-transfer
Feb 7, 2026
Merged

feat: org ownership transfer#760
nimish-ks merged 38 commits intomainfrom
feat--org-ownership-transfer

Conversation

@nimish-ks
Copy link
Member

@nimish-ks nimish-ks commented Feb 5, 2026

🔍 Overview

This PR implements the functionality to transfer organisation ownership from the current owner to another member. It introduces a new "Danger Zone" section in the Organisation Settings page, allowing the owner to securely transfer their role. Additionally, it includes UI fixes for double scrollbars observed in the Settings and Access pages.

Docs: phasehq/docs#201

💡 Proposed Changes

Organisation Ownership Transfer

  • New Feature Location: Moved the ownership transfer workflow from the Member's Role dropdown to Settings > Organisation > Danger Zone.
  • New Component: Created TransferOwnershipSection which handles the UI for initiating the transfer.
  • Backend Mutation: Added transferOrganisationOwnership mutation which:
    • Verifies the new owner has global access (Admin role).
    • Swaps the roles (Current Owner → Admin, New Owner → Owner).
    • Updates the Organisation's identity_key to match the new owner's.
    • Updates the Stripe customer email (Cloud mode only).
  • Billing Email: Added an input field in the confirmation dialog (Cloud mode only) to allow updating the billing email address during transfer.
  • Safety Checks: The UI restricts selection to members who already have Global Access to ensure cryptographic keys are available.

UI/UX Improvements

  • Scrollbar Fixes: Resolved double scrollbar issues in:
    • app/[team]/settings/page.tsx
    • app/[team]/access/layout.tsx
    • app/[team]/access/members/[memberId]/page.tsx
  • Revert: Reverted previous changes to RoleSelector.tsx to maintain separation of concerns.

🖼️ Screenshots or Demo

(Add screenshots of the new Danger Zone section and the Transfer Ownership modal here)

📝 Release Notes

  • New Feature: Organisation Owners can now transfer ownership to another Admin via Settings > Organisation.
  • Improvement: Fixed layout issues causing double scrollbars in Settings and Member pages.
  • Note: Transferring ownership is irreversible and requires the new owner to have a valid account recovery kit backed up.

❓ Open Questions

  • None at this time.

🧪 Testing

  • Ownership Transfer: Verified that ownership can be transferred to an existing Admin.
  • Permissions: Verified that non-global users cannot be selected as new owners.
  • Stripe Integration: Checked that update_stripe_customer_email is called with the provided email.
  • UI Layout: Confirmed that double scrollbars are removed on the targeted pages.

🎯 Reviewer Focus

  • frontend/components/settings/organisation/TransferOwnershipSection.tsx: Main UI logic for the feature.
  • backend/backend/graphene/mutations/organisation.py: Core backend logic for the transfer.
  • frontend/app/[team]/settings/page.tsx: Integration of the new section and layout fixes.

➕ Additional Context

The transfer process requires the new owner to have global access (Admin role) because they need to be able to decrypt all environment keys. The backend enforces this check.

✨ How to Test the Changes Locally

  1. Log in as an Organisation Owner.
  2. Navigate to Settings > Organisation.
  3. Scroll to the Danger Zone at the bottom.
  4. Click Transfer Ownership.
  5. Select a user (must be an Admin) from the dropdown.
  6. (Optional) Update the billing email if visible.
  7. Confirm the warnings and click Transfer.
  8. Verify you are logged out and the role has changed upon logging back in.

💚 Did You...

  • Ensure linting passes (code style checks)?
  • Update dependencies and lockfiles (if required)
  • Update migrations (if required)
  • Regenerate graphql schema and types (if required)
  • Verify the app builds locally?
  • Manually test the changes on different browsers/devices?

…ransfer in organisations

This mutation allows the current owner of an organisation to transfer ownership to another member, ensuring the new owner has the necessary admin role and updating relevant roles and Stripe customer email as needed.
…ransfer

This function updates the Stripe customer email when an organisation's ownership is transferred, ensuring accurate customer information. It includes error handling and notifications for failures.
This update integrates the TransferOrganisationOwnershipMutation into the Mutation class, allowing for the management of organisation ownership transfers within the GraphQL API.
This commit introduces a new GraphQL mutation, TransferOrganisationOwnership, which facilitates the transfer of ownership for an organisation. It accepts parameters for the organisation ID, new owner ID, and optional billing email, enhancing the API's functionality for managing ownership transitions.
…n ownership transfers

This commit introduces the TransferOwnershipSection component, allowing current owners to transfer ownership of an organisation to eligible members. It includes a dialog for selecting a new owner, checks for global access permissions, and provides user feedback on the transfer process. The component integrates with existing GraphQL queries and mutations to facilitate the ownership transfer functionality.
This update adds the TransferOwnershipSection component to the organisation settings page, enhancing the user interface for managing ownership transfers. The new section provides a seamless experience for current owners to initiate ownership transfers directly within the settings.
Copy link
Contributor

Copilot AI left a comment

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 implements organisation ownership transfer functionality, allowing owners to transfer their role to another admin member. The feature is implemented with a new "Danger Zone" section in Organisation Settings, includes backend validation and Stripe billing integration, and fixes UI scrollbar issues.

Changes:

  • Adds organisation ownership transfer mutation and UI workflow with security validations
  • Integrates Stripe customer email update for cloud-hosted instances
  • Fixes double scrollbar issues in Settings and Access pages

Reviewed changes

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

Show a summary per file
File Description
frontend/graphql/mutations/organisation/transferOwnership.gql GraphQL mutation definition for transferring organisation ownership
frontend/components/settings/organisation/TransferOwnershipSection.tsx Main UI component implementing the ownership transfer workflow with member selection and confirmation
frontend/app/[team]/settings/page.tsx Integrates TransferOwnershipSection into settings page and removes overflow-y-auto to fix scrollbar issue
frontend/app/[team]/access/layout.tsx Updates layout styling to use flex-1 overflow-y-auto to fix double scrollbar
backend/ee/billing/stripe.py Adds update_stripe_customer_email function to update Stripe customer when ownership changes
backend/backend/schema.py Registers the new TransferOrganisationOwnershipMutation in the GraphQL schema
backend/backend/graphene/mutations/organisation.py Implements backend mutation with role swapping, org identity_key update, and Stripe integration

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

This commit introduces two new email templates: one for the new owner and another for the old owner, notifying them of the ownership transfer. The templates provide personalized messages and relevant links to enhance user experience during the transition.
This commit adds functionality to send email notifications to both the old and new owners during the organisation ownership transfer process. It includes error handling for potential issues when sending the emails.
This commit introduces a new Checkbox component, allowing users to select options with customizable sizes and labels. The component includes accessibility features and visual feedback for checked states, enhancing the user interface for forms and settings.
…tion and UI updates

This commit refactors the TransferOwnershipSection component to utilize a Combobox for member selection, improving user experience. It introduces a new Alert component for better feedback and updates the dialog to fetch eligible members dynamically. The UI has been streamlined with clearer messaging and improved layout, ensuring a more intuitive ownership transfer process.
This commit introduces a comprehensive suite of unit tests for the permission utilities, including functions like userHasGlobalAccess, userIsAdmin, userHasPermission, and parsePermissions. The tests cover various scenarios, ensuring robust validation of permission logic and handling of different permission structures. This addition enhances code reliability and facilitates future development.
This commit introduces a comprehensive suite of unit tests for the TransferOrganisationOwnershipMutation GraphQL mutation. The tests cover various scenarios, including successful ownership transfers, permission checks for non-owners, and restrictions against transferring ownership to oneself or to members without global access. This addition enhances the reliability of the ownership transfer functionality and ensures proper handling of edge cases.
…rshipMutation

This commit adds a check to ensure that the new owner has a valid identity key before transferring ownership. If the identity key is missing, a GraphQLError is raised, prompting the user to complete their account setup. This enhancement improves the robustness of the ownership transfer process by ensuring that only eligible members can be assigned ownership.
This commit introduces two unit tests to validate that ownership cannot be transferred to members with null or empty identity keys. Both tests ensure that a GraphQLError is raised with appropriate messages, enhancing the robustness of the TransferOrganisationOwnershipMutation by enforcing identity key requirements.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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


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

Copy link
Member

@rohan-chaturvedi rohan-chaturvedi left a comment

Choose a reason for hiding this comment

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

A few suggestions. Also, I think you missed updating the graphql schema and frontend types

…alog for improved ownership transfer flow

This commit refactors the TransferOwnershipSection component by removing unnecessary state management and integrating a GenericDialog for handling the ownership transfer process. It enhances the user experience by ensuring that only owners can access the transfer functionality and simplifies the dialog management with a reference. The overall structure is optimized for better readability and maintainability.
nimish-ks and others added 16 commits February 7, 2026 14:58
…OrganisationOwnershipMutation

This commit enhances the TransferOrganisationOwnershipMutation by wrapping the ownership transfer process in a database transaction. This ensures that all changes are applied atomically, preventing inconsistent states during the transfer of ownership. The changes include setting the new owner's role, updating the organisation's identity key, and demoting the current owner, all within a single transaction block.
…tion.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Nimish <85357445+nimish-ks@users.noreply.github.com>
This commit updates the test cases in test_transfer_ownership.py to include a mock transaction for the ownership transfer process. The changes ensure that the transaction is properly mocked in various test scenarios, enhancing the reliability of the tests and maintaining consistency in the ownership transfer logic.
…s into single-line definitions

This commit refactors the GraphQL schema by consolidating multiline argument definitions into single-line format for better readability and consistency. Additionally, it updates comments to a more concise format while maintaining clarity.
This commit introduces the TransferOrganisationOwnership mutation to the GraphQL schema, allowing for the transfer of organisation ownership between members. It includes the necessary types and arguments for the mutation, ensuring that the new owner has the required permissions. Additionally, it updates the AppType to accommodate potential null values for service accounts.
Signed-off-by: rohan <rohan.chaturvedi@protonmail.com>
Signed-off-by: rohan <rohan.chaturvedi@protonmail.com>
@nimish-ks nimish-ks merged commit 69dee6b into main Feb 7, 2026
7 checks passed
@nimish-ks nimish-ks deleted the feat--org-ownership-transfer branch February 7, 2026 14:35
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.

2 participants