fix: keep restricted roles from creating a fork through a session move

The move's fork gate checked only the workspace's forking rule. A role
missing a capability would get the default role in a fork it creates, so
the gate also refuses restricted roles, as the workspace picker does.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Guilhem Lemouel
2026-10-26 10:53:08 -07:00
co-authored by Claude Opus 5.5
parent 21240cf6f9
commit cdd6fb2ca7
@@ -19,6 +19,7 @@
} from '$lib/utils/workspaceHierarchy'
import { useForkableWorkspaces } from '$lib/utils/useForkableWorkspaces.svelte'
import { canCreateFork } from '$lib/utils/editInFork'
import { capabilitiesIn, isRestricted } from '$lib/roleCapabilities'
import { forkAccentStyle } from '$lib/utils/forkColor'
import { WorkspaceService } from '$lib/gen'
import { useSessionReadOnly } from './sessionPermissions.svelte'
@@ -190,6 +191,13 @@
? forksOf !== 'admins' &&
!rootRulesetsResource.loading &&
!rootUserInfoResource.loading &&
// A restricted role would get the default role in the fork it creates.
!isRestricted(
capabilitiesIn(
rootUserInfo,
$userWorkspaces.find((w) => w.id === forksOf)
)
) &&
(!isRuleActiveInRulesets(rootRulesets, 'DisableWorkspaceForking') ||
canUserBypassRuleKindInRulesets(rootRulesets, 'DisableWorkspaceForking', rootUserInfo))
: $workspaceStore !== 'admins' &&