diff --git a/apps/sim/app/api/auth/[...all]/route.test.ts b/apps/sim/app/api/auth/[...all]/route.test.ts index d9aa74cab91..f87f1a01673 100644 --- a/apps/sim/app/api/auth/[...all]/route.test.ts +++ b/apps/sim/app/api/auth/[...all]/route.test.ts @@ -8,11 +8,9 @@ const handlerMocks = vi.hoisted(() => ({ betterAuthGET: vi.fn(), betterAuthPOST: vi.fn(), ensureAnonymousUserExists: vi.fn(), - createAnonymousGetSessionResponse: vi.fn(() => ({ - data: { - user: { id: 'anon' }, - session: { id: 'anon-session' }, - }, + createAnonymousSession: vi.fn(() => ({ + user: { id: 'anon' }, + session: { id: 'anon-session' }, })), isAuthDisabled: false, })) @@ -30,7 +28,7 @@ vi.mock('@/lib/auth', () => ({ vi.mock('@/lib/auth/anonymous', () => ({ ensureAnonymousUserExists: handlerMocks.ensureAnonymousUserExists, - createAnonymousGetSessionResponse: handlerMocks.createAnonymousGetSessionResponse, + createAnonymousSession: handlerMocks.createAnonymousSession, })) vi.mock('@/lib/core/config/feature-flags', () => ({ @@ -63,10 +61,8 @@ describe('auth catch-all route (DISABLE_AUTH get-session)', () => { expect(handlerMocks.ensureAnonymousUserExists).toHaveBeenCalledTimes(1) expect(handlerMocks.betterAuthGET).not.toHaveBeenCalled() expect(json).toEqual({ - data: { - user: { id: 'anon' }, - session: { id: 'anon-session' }, - }, + user: { id: 'anon' }, + session: { id: 'anon-session' }, }) }) diff --git a/apps/sim/app/api/auth/[...all]/route.ts b/apps/sim/app/api/auth/[...all]/route.ts index b09ce7e7e67..6ff9bfd6db2 100644 --- a/apps/sim/app/api/auth/[...all]/route.ts +++ b/apps/sim/app/api/auth/[...all]/route.ts @@ -1,7 +1,7 @@ import { toNextJsHandler } from 'better-auth/next-js' import { type NextRequest, NextResponse } from 'next/server' import { auth } from '@/lib/auth' -import { createAnonymousGetSessionResponse, ensureAnonymousUserExists } from '@/lib/auth/anonymous' +import { createAnonymousSession, ensureAnonymousUserExists } from '@/lib/auth/anonymous' import { isAuthDisabled } from '@/lib/core/config/feature-flags' import { withRouteHandler } from '@/lib/core/utils/with-route-handler' @@ -24,7 +24,7 @@ export const GET = withRouteHandler(async (request: NextRequest) => { if (path === 'get-session' && isAuthDisabled) { await ensureAnonymousUserExists() - return NextResponse.json(createAnonymousGetSessionResponse()) + return NextResponse.json(createAnonymousSession()) } return betterAuthGET(request) diff --git a/apps/sim/lib/auth/anonymous.ts b/apps/sim/lib/auth/anonymous.ts index 839e65487ec..7504ee7fd62 100644 --- a/apps/sim/lib/auth/anonymous.ts +++ b/apps/sim/lib/auth/anonymous.ts @@ -103,7 +103,3 @@ export function createAnonymousSession(): AnonymousSession { }, } } - -export function createAnonymousGetSessionResponse(): { data: AnonymousSession } { - return { data: createAnonymousSession() } -}