Merge pull request #38 from yusufipk/fix/public-project-hides-workspace-admin-actions

fix(auth): keep workspace admin permissions on public projects
This commit is contained in:
Yusuf İpek
2026-07-25 13:18:38 +03:00
committed by GitHub
+7 -3
View File
@@ -281,9 +281,13 @@ export async function checkProjectAccess(
const isProjectMember = !!projectMember; const isProjectMember = !!projectMember;
const isProjectAdmin = projectMember?.role === ProjectMemberRole.ADMIN; const isProjectAdmin = projectMember?.role === ProjectMemberRole.ADMIN;
const needsWorkspaceForAccess = !!userId && !isOwner && !isProjectMember && !isPublic; // The workspace role decides `canEdit`/`isWorkspaceMember`, not just whether the viewer
const needsWorkspaceForActions = !!userId && !isOwner && intent !== 'view'; // gets in at all, so it has to be resolved for every signed-in non-owner. Skipping it
const shouldLoadWorkspaceRole = needsWorkspaceForAccess || needsWorkspaceForActions; // once access was already granted some other way (public project, or an existing project
// membership) silently downgraded workspace admins to read-only on `intent: 'view'` —
// the intent pages and GET routes use to decide which actions to render.
// Owners pass every check on their own; resolve their role only when they mutate.
const shouldLoadWorkspaceRole = !!userId && (!isOwner || intent !== 'view');
// Check workspace membership/role // Check workspace membership/role
let workspaceRole: WorkspaceMemberRole | 'OWNER' | null = null; let workspaceRole: WorkspaceMemberRole | 'OWNER' | null = null;