diff --git a/app/actions.ts b/app/actions.ts index 41e8b0d65..e50c5f9dc 100644 --- a/app/actions.ts +++ b/app/actions.ts @@ -5,7 +5,7 @@ import { redirect } from 'next/navigation' import { auth } from '@/auth' import { type Chat } from '@/lib/types' -import { createClient } from '@/utils/supabase/server' +import { createClient } from '@supabase-labs/nextjs/server' export async function getChats(userId?: string | null) { const session = await auth() @@ -30,7 +30,7 @@ export async function getChats(userId?: string | null) { .eq('user_id', userId) .throwOnError() - return data?.map(chat => chat.payload as Chat) ?? [] + return data?.map(chat => chat.payload).filter(chat => chat !== null) ?? [] } catch (error) { return [] } @@ -53,7 +53,7 @@ export async function getChat(id: string, userId: string) { .eq('id', id) .maybeSingle() - return (data?.payload as Chat) ?? null + return data?.payload ?? null } export async function removeChat({ id, path }: { id: string; path: string }) { @@ -114,7 +114,7 @@ export async function getSharedChat(id: string) { .not('payload->sharePath', 'is', null) .maybeSingle() - return (data?.payload as Chat) ?? null + return data?.payload ?? null } export async function shareChat(id: string) { @@ -134,7 +134,7 @@ export async function shareChat(id: string) { .eq('id', id) .maybeSingle() - const chat = data?.payload as Chat | null + const chat = data?.payload ?? null if (!chat || chat.userId !== session.user.id) { return { diff --git a/app/auth/confirm/route.ts b/app/auth/confirm/route.ts deleted file mode 100644 index d341d85e4..000000000 --- a/app/auth/confirm/route.ts +++ /dev/null @@ -1,23 +0,0 @@ -import type { EmailOtpType } from '@supabase/supabase-js' -import { createClient } from '@/utils/supabase/server' -import { redirect } from 'next/navigation' - -export async function GET(request: Request) { - const { searchParams } = new URL(request.url) - const token_hash = searchParams.get('token_hash') - const type = searchParams.get('type') as EmailOtpType | null - const next = searchParams.get('next') ?? '/' - - if (token_hash && type) { - const supabase = createClient() - - const { error } = await supabase.auth.verifyOtp({ - type, - token_hash - }) - if (!error) { - // redirect user to specified redirect URL or root of app - redirect(next) - } - } -} diff --git a/app/login/actions.ts b/app/login/actions.ts index 43df802de..6df00732e 100644 --- a/app/login/actions.ts +++ b/app/login/actions.ts @@ -2,7 +2,7 @@ import { z } from 'zod' import { ResultCode } from '@/lib/utils' -import { createClient } from '@/utils/supabase/server' +import { createClient } from '@supabase-labs/nextjs/server' interface Result { type: string diff --git a/app/login/page.tsx b/app/login/page.tsx index 1fba27bea..2dd7ac2c8 100644 --- a/app/login/page.tsx +++ b/app/login/page.tsx @@ -1,15 +1,6 @@ -import { auth } from '@/auth' import LoginForm from '@/components/login-form' -import { Session } from '@/lib/types' -import { redirect } from 'next/navigation' export default async function LoginPage() { - const session = (await auth()) as Session - - if (session) { - redirect('/') - } - return (
diff --git a/app/signup/actions.ts b/app/signup/actions.ts index ed3004c93..9f99df10c 100644 --- a/app/signup/actions.ts +++ b/app/signup/actions.ts @@ -2,7 +2,7 @@ import { ResultCode } from '@/lib/utils' import { z } from 'zod' -import { createClient } from '@/utils/supabase/server' +import { createClient } from '@supabase-labs/nextjs/server' import { headers } from 'next/headers' interface Result { type: string diff --git a/app/signup/page.tsx b/app/signup/page.tsx index dbac96428..1b33b3ca6 100644 --- a/app/signup/page.tsx +++ b/app/signup/page.tsx @@ -1,15 +1,6 @@ -import { auth } from '@/auth' import SignupForm from '@/components/signup-form' -import { Session } from '@/lib/types' -import { redirect } from 'next/navigation' export default async function SignupPage() { - const session = (await auth()) as Session - - if (session) { - redirect('/') - } - return (
diff --git a/auth.ts b/auth.ts index ed344edac..8f1b236a4 100644 --- a/auth.ts +++ b/auth.ts @@ -1,4 +1,4 @@ -import { createClient } from '@/utils/supabase/server' +import { createClient } from '@supabase-labs/nextjs/server' import { Session } from '@/lib/types' export async function auth(): Promise { diff --git a/components/ui/codeblock.tsx b/components/ui/codeblock.tsx index 1bde5acb5..21fd76ea8 100644 --- a/components/ui/codeblock.tsx +++ b/components/ui/codeblock.tsx @@ -68,7 +68,7 @@ const CodeBlock: FC = memo(({ language, value }) => { 3, true )}${fileExtension}` - const fileName = window.prompt('Enter file name' || '', suggestedFileName) + const fileName = window.prompt('Enter file name', suggestedFileName) if (!fileName) { // User pressed cancel on prompt. diff --git a/components/user-menu.tsx b/components/user-menu.tsx index 42c42494f..0a44dbf0d 100644 --- a/components/user-menu.tsx +++ b/components/user-menu.tsx @@ -8,7 +8,7 @@ import { DropdownMenuSeparator, DropdownMenuTrigger } from '@/components/ui/dropdown-menu' -import { createClient } from '@/utils/supabase/server' +import { createClient } from '@supabase-labs/nextjs/server' import { redirect } from 'next/navigation' export interface UserMenuProps { @@ -42,7 +42,7 @@ export function UserMenu({ user }: UserMenuProps) { 'use server' const supabase = createClient() await supabase.auth.signOut() - redirect('/login') + redirect('/') }} >