Repository navigation
[Step 2]: Rework team layout persist - #6779
Open
RobertJoonas wants to merge 6 commits into
Open
RobertJoonas wants to merge 6 commits into
RobertJoonas wants to merge 6 commits into
Conversation
RobertJoonas
changed the base branch from
master
to
refactor-teams-layout-persist-1
October 14, 2026 17:34
aerosol
reviewed
Oct 15, 2026
zoldar
reviewed
Oct 15, 2026
RobertJoonas
added this pull request to stack #6783
October 15, 2026 11:42
Currently, invitations and memberships both maintain their own separate version of "who can grant what role to who" logic. This commit brings those two closer together and makes sure that the shared functionality is not duplicated. While this was meant to be a refactor, a few bugs / inconsistencies were discovered and fixed while moving the two under the same roof: - An Admin couldn't change an Owner's role, but could change a pending Owner invitation to any other role. And then again, couldn't create a new invitation with the Owner role. FIX: Prohibit demoting Owner role even on pending invitations. - Changing your own role was handled separately, which rejected keeping your own Owner or Admin role, but the same no-op was allowed when changing someone else's role. FIX: No separate "can_grant_to_self?" function anymore. Assigning to self is the same as assigning to someone else with the same role as you. The no-op role changes are allowed in both cases. - Role validation lived in each caller, and the invitation check compared roles to atoms while also accepting strings. While it's impossible in practice currently, an Admin passing "owner" as string would get past the owners-only rule. FIX: Move role validation deeper and accept only atoms. The only intended difference between invitations and memberships was kept: an Admin may change pending billing invitations, but not billing members, since billing members might already have access to the subscription, which admins don't.
Currently, team management changes a pending invitation's role by inviting the same email again. Under the hood, that's a write action (not an update) which due to a unique(team_id, email) conflict overwrites the existing row. This commit makes it an explicit update action, and it's not purely cosmetic. Since recent commits, the backend now rejects a new invitation if a pending one already exists (instead of overwriting it). So this is actually needed.
RobertJoonas
force-pushed
the
refactor-teams-layout-persist-2
branch
from
October 15, 2026 12:39
149236f to
fa3228a
Compare
zoldar
approved these changes
Oct 15, 2026
RobertJoonas
force-pushed
the
refactor-teams-layout-persist-2
branch
from
October 15, 2026 17:38
89118c4 to
5d9d734
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
TeamRolePermissionsmodule with its own tests. It exposes two functions:ensure_can_grant_for_memberandensure_can_grant_for_invitation. The functions now share most of the role permissions logic."owner"as a string would have got past the owners-only rule (not reachable in practice). Roles are now validated in one place, and only atoms are accepted.Invitations.UpdateRolefunction (not used yet; will be in step 3) which changes the role of a pending team invitation without sending an e-mail and without resetting its expiry. Updating the role of an existing invitation currently works with an upsert. This makes it an explicit update action.Tests
Changelog
Documentation
Dark mode