MCPcopy Index your code
hub / github.com/simstudioai/sim / verifyWorkflowAccess

Function verifyWorkflowAccess

apps/sim/lib/copilot/auth/permissions.ts:14–37  ·  view source on GitHub ↗
(
  userId: string,
  workflowId: string
)

Source from the content-addressed store, hash-verified

12 * @returns Promise<{ hasAccess: boolean; userPermission: PermissionType | null; workspaceId?: string }>
13 */
14export async function verifyWorkflowAccess(
15 userId: string,
16 workflowId: string
17): Promise<{
18 hasAccess: boolean
19 userPermission: PermissionType | null
20 workspaceId?: string
21}> {
22 try {
23 const result = await authorizeWorkflowByWorkspacePermission({
24 workflowId,
25 userId,
26 action: 'read',
27 })
28 return {
29 hasAccess: result.allowed,
30 userPermission: result.workspacePermission,
31 workspaceId: result.workflow?.workspaceId ?? undefined,
32 }
33 } catch (error) {
34 logger.error('Error verifying workflow access', { error, workflowId, userId })
35 return { hasAccess: false, userPermission: null }
36 }
37}
38
39/**
40 * Helper function to create consistent permission error messages

Callers 2

executeFunction · 0.90

Calls 2

errorMethod · 0.80

Tested by

no test coverage detected