Skip to content

Commit dfddb60

Browse files
committed
fix(skills): consolidate redundant permission checks in POST and DELETE
1 parent 6fea21c commit dfddb60

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

apps/sim/app/api/skills/route.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,7 @@ export async function POST(req: NextRequest) {
8989
}
9090

9191
const userPermission = await getUserEntityPermissions(userId, 'workspace', workspaceId)
92-
if (!userPermission) {
93-
logger.warn(
94-
`[${requestId}] User ${userId} does not have access to workspace ${workspaceId}`
95-
)
96-
return NextResponse.json({ error: 'Access denied' }, { status: 403 })
97-
}
98-
99-
if (userPermission !== 'admin' && userPermission !== 'write') {
92+
if (!userPermission || (userPermission !== 'admin' && userPermission !== 'write')) {
10093
logger.warn(
10194
`[${requestId}] User ${userId} does not have write permission for workspace ${workspaceId}`
10295
)
@@ -159,12 +152,7 @@ export async function DELETE(request: NextRequest) {
159152
}
160153

161154
const userPermission = await getUserEntityPermissions(userId, 'workspace', workspaceId)
162-
if (!userPermission) {
163-
logger.warn(`[${requestId}] User ${userId} does not have access to workspace ${workspaceId}`)
164-
return NextResponse.json({ error: 'Access denied' }, { status: 403 })
165-
}
166-
167-
if (userPermission !== 'admin' && userPermission !== 'write') {
155+
if (!userPermission || (userPermission !== 'admin' && userPermission !== 'write')) {
168156
logger.warn(
169157
`[${requestId}] User ${userId} does not have write permission for workspace ${workspaceId}`
170158
)

0 commit comments

Comments
 (0)