File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
apps/sim/app/api/auth/oauth2/authorize-params Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -3,13 +3,19 @@ import { verification } from '@sim/db/schema'
33import { eq } from 'drizzle-orm'
44import type { NextRequest } from 'next/server'
55import { NextResponse } from 'next/server'
6+ import { getSession } from '@/lib/auth'
67
78/**
89 * Returns the original OAuth authorize parameters stored in the verification record
910 * for a given consent code. Used by the consent page to reconstruct the authorize URL
1011 * when switching accounts.
1112 */
1213export async function GET ( request : NextRequest ) {
14+ const session = await getSession ( )
15+ if ( ! session ?. user ) {
16+ return NextResponse . json ( { error : 'Unauthorized' } , { status : 401 } )
17+ }
18+
1319 const consentCode = request . nextUrl . searchParams . get ( 'consent_code' )
1420 if ( ! consentCode ) {
1521 return NextResponse . json ( { error : 'consent_code is required' } , { status : 400 } )
@@ -29,12 +35,17 @@ export async function GET(request: NextRequest) {
2935 clientId : string
3036 redirectURI : string
3137 scope : string [ ]
38+ userId : string
3239 codeChallenge : string
3340 codeChallengeMethod : string
3441 state : string | null
3542 nonce : string | null
3643 }
3744
45+ if ( data . userId !== session . user . id ) {
46+ return NextResponse . json ( { error : 'Forbidden' } , { status : 403 } )
47+ }
48+
3849 return NextResponse . json ( {
3950 client_id : data . clientId ,
4051 redirect_uri : data . redirectURI ,
You can’t perform that action at this time.
0 commit comments