File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
apps/sim/app/api/copilot/chat Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 11import { and , desc , eq } from 'drizzle-orm'
22import { type NextRequest , NextResponse } from 'next/server'
33import { z } from 'zod'
4+ import { getSession } from '@/lib/auth'
45import {
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
You can’t perform that action at this time.
0 commit comments