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

Function checkTableWriteAccess

apps/sim/app/api/table/utils.ts:166–179  ·  view source on GitHub ↗

* Check if a user has write access to a table. * Write access requires write or admin workspace permission.

(tableId: string, userId: string)

Source from the content-addressed store, hash-verified

164 * Write access requires write or admin workspace permission.
165 */
166async function checkTableWriteAccess(tableId: string, userId: string): Promise<TableAccessCheck> {
167 const table = await getTableById(tableId)
168
169 if (!table) {
170 return { hasAccess: false, notFound: true }
171 }
172
173 const userPermission = await getUserEntityPermissions(userId, 'workspace', table.workspaceId)
174 if (permissionSatisfies(userPermission, 'write')) {
175 return { hasAccess: true, table }
176 }
177
178 return { hasAccess: false, reason: 'User does not have write access to this table' }
179}
180
181/**
182 * Access check returning `{ ok, table }` or `{ ok: false, status }`.

Callers

nothing calls this directly

Calls 3

getTableByIdFunction · 0.90
getUserEntityPermissionsFunction · 0.90
permissionSatisfiesFunction · 0.85

Tested by

no test coverage detected