diff --git a/src/api/supabase/queries/user_queries.ts b/src/api/supabase/queries/user_queries.ts index 6b374796..c12ecb5d 100644 --- a/src/api/supabase/queries/user_queries.ts +++ b/src/api/supabase/queries/user_queries.ts @@ -10,13 +10,20 @@ import { convertButtonNumberToCategory } from './button_queries'; */ export async function fetchUser(): Promise { const { - data: { user }, + data: { session }, error, - } = await supabase.auth.getUser(); + } = await supabase.auth.getSession(); + if (error) { - throw new Error(`Error fetching user: ${error.message}`); + throw new Error(`Error fetching session: ${error.message}`); + } + + if (!session) { + throw new Error(`Session is null`); } + const user = session.user; + if (user !== null) { const { data, error: error1 } = await supabase .from('profiles') diff --git a/src/app/[productId]/page.tsx b/src/app/[productId]/page.tsx index f93bd3d3..3a45652a 100644 --- a/src/app/[productId]/page.tsx +++ b/src/app/[productId]/page.tsx @@ -62,7 +62,7 @@ export default function ItemDisplay({ {Item?.name}