From 815d3c900b3c2f47a897188081aee9a650f0dfa7 Mon Sep 17 00:00:00 2001 From: Ram <> Date: Mon, 30 Dec 2024 21:44:45 +0000 Subject: [PATCH 1/2] fix: changed Supabase getSession API to getUser --- apps/forms/app/(workspace)/dashboard/new/page.tsx | 2 +- apps/forms/middleware.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/forms/app/(workspace)/dashboard/new/page.tsx b/apps/forms/app/(workspace)/dashboard/new/page.tsx index 4968b02e6..a6d9486d0 100644 --- a/apps/forms/app/(workspace)/dashboard/new/page.tsx +++ b/apps/forms/app/(workspace)/dashboard/new/page.tsx @@ -31,7 +31,7 @@ export default async function OnboardWithNewFormPage({ const supabase = createServerComponentClient(cookieStore); - const { data } = await supabase.auth.getSession(); + const { data } = await supabase.auth.getUser(); // if no auth, sign in, redirect back here if (data.session === null || data.session.user === null) { const search = new URLSearchParams(searchParams).toString(); diff --git a/apps/forms/middleware.ts b/apps/forms/middleware.ts index 9cba492a7..fff26c626 100644 --- a/apps/forms/middleware.ts +++ b/apps/forms/middleware.ts @@ -51,7 +51,7 @@ export async function middleware(req: NextRequest) { const supabase = createMiddlewareClient({ req, res }); // Refresh session if expired - required for Server Components - await supabase.auth.getSession(); + await supabase.auth.getUser(); return res; } From 8bea06494dc873c417b9beb75eff269e9636ab11 Mon Sep 17 00:00:00 2001 From: Ram <> Date: Mon, 30 Dec 2024 22:13:26 +0000 Subject: [PATCH 2/2] updated auth user check --- apps/forms/app/(workspace)/dashboard/new/page.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/forms/app/(workspace)/dashboard/new/page.tsx b/apps/forms/app/(workspace)/dashboard/new/page.tsx index a6d9486d0..06473e517 100644 --- a/apps/forms/app/(workspace)/dashboard/new/page.tsx +++ b/apps/forms/app/(workspace)/dashboard/new/page.tsx @@ -31,9 +31,9 @@ export default async function OnboardWithNewFormPage({ const supabase = createServerComponentClient(cookieStore); - const { data } = await supabase.auth.getUser(); + const { data: auth } = await supabase.auth.getUser(); // if no auth, sign in, redirect back here - if (data.session === null || data.session.user === null) { + if (!auth.user) { const search = new URLSearchParams(searchParams).toString(); const uri = encodeURIComponent("/dashboard/new?" + search); redirect("/sign-in?redirect_uri=" + uri);