Skip to content

Commit b613010

Browse files
authored
Add basic personalizatoin (#868)
1 parent 1035aca commit b613010

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

apps/sim/app/api/copilot/chat/route.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { and, desc, eq } from 'drizzle-orm'
22
import { type NextRequest, NextResponse } from 'next/server'
33
import { z } from 'zod'
4+
import { getSession } from '@/lib/auth'
45
import {
56
authenticateCopilotRequestSessionOnly,
67
createBadRequestResponse,
@@ -125,14 +126,15 @@ export async function POST(req: NextRequest) {
125126
const tracker = createRequestTracker()
126127

127128
try {
128-
// Authenticate user using consolidated helper
129-
const { userId: authenticatedUserId, isAuthenticated } =
130-
await authenticateCopilotRequestSessionOnly()
129+
// Get session to access user information including name
130+
const session = await getSession()
131131

132-
if (!isAuthenticated || !authenticatedUserId) {
132+
if (!session?.user?.id) {
133133
return createUnauthorizedResponse()
134134
}
135135

136+
const authenticatedUserId = session.user.id
137+
136138
const body = await req.json()
137139
const {
138140
message,
@@ -242,6 +244,7 @@ export async function POST(req: NextRequest) {
242244
stream: stream,
243245
streamToolCalls: true,
244246
mode: mode,
247+
...(createNewChat && session?.user?.name && { userName: session.user.name }),
245248
}),
246249
})
247250

0 commit comments

Comments
 (0)