Skip to content

Commit 5ddfe1b

Browse files
fix(sockets): permissions to align with normal perms system" (#782)
1 parent 022a61b commit 5ddfe1b

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

apps/sim/socket-server/middleware/permissions.ts

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ export async function verifyWorkflowAccess(
4141

4242
const { userId: workflowUserId, workspaceId, name: workflowName } = workflowData[0]
4343

44-
// Check if user owns the workflow
44+
// Check if user owns the workflow - treat as admin
4545
if (workflowUserId === userId) {
46-
logger.debug(`User ${userId} has owner access to workflow ${workflowId} (${workflowName})`)
47-
return { hasAccess: true, role: 'owner', workspaceId: workspaceId || undefined }
46+
logger.debug(
47+
`User ${userId} has admin access to workflow ${workflowId} (${workflowName}) as owner`
48+
)
49+
return { hasAccess: true, role: 'admin', workspaceId: workspaceId || undefined }
4850
}
4951

5052
// Check workspace membership if workflow belongs to a workspace
@@ -90,19 +92,6 @@ export async function verifyOperationPermission(
9092

9193
// Define operation permissions based on role
9294
const rolePermissions = {
93-
owner: [
94-
'add',
95-
'remove',
96-
'update',
97-
'update-position',
98-
'update-name',
99-
'toggle-enabled',
100-
'update-parent',
101-
'update-wide',
102-
'update-advanced-mode',
103-
'toggle-handles',
104-
'duplicate',
105-
],
10695
admin: [
10796
'add',
10897
'remove',
@@ -116,7 +105,7 @@ export async function verifyOperationPermission(
116105
'toggle-handles',
117106
'duplicate',
118107
],
119-
member: [
108+
write: [
120109
'add',
121110
'remove',
122111
'update',
@@ -129,7 +118,7 @@ export async function verifyOperationPermission(
129118
'toggle-handles',
130119
'duplicate',
131120
],
132-
viewer: ['update-position'], // Viewers can only move things around
121+
read: ['update-position'], // Read-only users can only move things around
133122
}
134123

135124
const allowedOperations = rolePermissions[accessInfo.role as keyof typeof rolePermissions] || []

0 commit comments

Comments
 (0)