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

Function checkAccess

apps/sim/app/api/table/utils.ts:185–200  ·  view source on GitHub ↗
(
  tableId: string,
  userId: string,
  level: 'read' | 'write' | 'admin' = 'read'
)

Source from the content-addressed store, hash-verified

183 * Uses workspace permissions only.
184 */
185export async function checkAccess(
186 tableId: string,
187 userId: string,
188 level: 'read' | 'write' | 'admin' = 'read'
189): Promise<AccessResult> {
190 const table = await getTableById(tableId)
191
192 if (!table) {
193 return { ok: false, status: 404 }
194 }
195
196 const permission = await getUserEntityPermissions(userId, 'workspace', table.workspaceId)
197 const hasAccess = permissionSatisfies(permission, level)
198
199 return hasAccess ? { ok: true, table } : { ok: false, status: 403 }
200}
201
202export function accessError(
203 result: { ok: false; status: 404 | 403 },

Callers 15

route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
handleBatchInsertFunction · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90

Calls 3

getTableByIdFunction · 0.90
getUserEntityPermissionsFunction · 0.90
permissionSatisfiesFunction · 0.85

Tested by

no test coverage detected