-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Overview
Allow users and organizations to voluntarily revoke their own access to a farm. This enables advisors, researchers, or partner organizations to "clean up" their own dashboard without needing the farm owner's intervention.
1. Core Logic Updates (fdm-core)
farm.ts
revokePrincipalFromFarm(Refactor):- Self-Revocation Detection: If
target_id === principal_id(individual) OR iftarget_idis an Organization andprincipal_idis an Admin/Owner of that Organization, bypass thesharepermission requirement. - Ownership Guard: Check if the principal being revoked is an "owner". If so, verify that at least one other owner (individual or organization) remains.
- Active Farm Cleanup: If the individual user leaving has this farm set as
farm_activein their user profile, clear that field. - Audit Logging: Ensure the audit trail distinguishes between "Revoked by Admin" and "Self-Revoked/Left".
- Self-Revocation Detection: If
authorization.ts
- Ensure
revokePrincipalremains the underlying atomic operation for removing the role record.
2. Application Layer (fdm-app)
farm.$b_id_farm.settings.access.tsx
- UI Logic:
- Add a "Leave Farm" button for the current user's personal role.
- If the user is an Admin/Owner of an Organization listed in the access list, add a "Remove Organization from Farm" button for that organization.
- Inherited Access: If a user's access is inherited via an organization but they have no direct role, the personal "Leave" button should be disabled with a tooltip: "Access granted via Organization [Name]".
- Confirmation & Redirect:
- Use a confirmation dialog: "Are you sure? You will lose all access to this farm immediately."
- Crucial: Upon successful revocation, the action must redirect the user to the dashboard (
/farm) to avoid a 403 error on the settings page.
3. Security & Permissions
- Individual Self-Revocation: Always allowed for the authenticated user.
- Organization Self-Revocation: Restricted to Admins and Owners of the target organization.
- The "Last Owner" Rule: A farm cannot be orphaned. The last principal with the "owner" role cannot leave; they must either transfer ownership or delete the farm.
Benefits
- User Autonomy: Users and organization leads can manage their own farm lists.
- Data Hygiene: Prevents dashboard clutter for consultants and researchers.
- Safety: Prevents accidentally orphaning a farm by enforcing the last-owner rule.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels