Skip to content

Commit d945e65

Browse files
Update apps/sim/app/api/tools/command/exec/route.ts
add authentication check using session Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
1 parent e7553d1 commit d945e65

File tree

1 file changed

+9
-7
lines changed
  • apps/sim/app/api/tools/command/exec

1 file changed

+9
-7
lines changed

apps/sim/app/api/tools/command/exec/route.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@ import { spawn } from "child_process";
22
import { NextRequest, NextResponse } from "next/server";
33
import type { CommandInput, CommandOutput } from "@/tools/command/types";
44

5+
import { getSession } from '@/lib/auth'
6+
57
export async function POST(request: NextRequest) {
68
try {
7-
const params: CommandInput = await request.json();
8-
9-
// Validate input
10-
if (!params.command) {
9+
const session = await getSession()
10+
if (!session?.user?.id) {
1111
return NextResponse.json(
12-
{ error: "Command is required" },
13-
{ status: 400 },
14-
);
12+
{ error: 'Unauthorized' },
13+
{ status: 401 },
14+
)
1515
}
1616

17+
const params: CommandInput = await request.json()
18+
1719
// Set default values
1820
const workingDirectory = params.workingDirectory || process.cwd();
1921
const timeout = params.timeout || 30000;

0 commit comments

Comments
 (0)