From 7038665df245cc7a8cf1935557b190ed2d481377 Mon Sep 17 00:00:00 2001 From: amjed-ali-k Date: Sat, 14 Oct 2023 22:59:08 +0530 Subject: [PATCH] fix: key --- src/app/globals.css | 4 ++-- src/components/auth/server.ts | 28 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/app/globals.css b/src/app/globals.css index 4fea897..9b519a9 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -101,11 +101,11 @@ body { min-height: 100vh; - min-height: fill-available; + min-height: stretch; min-height: -webkit-fill-available; } html { - height: fill-available; + height: stretch; height: -webkit-fill-available; } diff --git a/src/components/auth/server.ts b/src/components/auth/server.ts index 3dff00a..2b4ad05 100644 --- a/src/components/auth/server.ts +++ b/src/components/auth/server.ts @@ -14,18 +14,18 @@ export const fetchUserId = async (hanko: string) => { }; export const getUserId = async (req: NextRequest) => { - const userId = req.headers.get("x-user-id"); - return userId; - // const hanko = req.cookies.get("hanko")?.value ?? ""; - // if (!hanko) { - // throw new Error("No Hanko cookie found"); - // } - // const userId = await fetchUserId(hanko); - // // validate userId is uuid using zod - // const schema = z.string().uuid(); - // const validatedUserId = schema.safeParse(userId); - // if (!validatedUserId.success) { - // throw new Error("Invalid user id"); - // } - // return validatedUserId.data; + // const userId = req.headers.get("x-user-id"); + // return userId; + const hanko = req.cookies.get("hanko")?.value ?? ""; + if (!hanko) { + return null; + } + const userId = await fetchUserId(hanko); + // validate userId is uuid using zod + const schema = z.string().uuid(); + const validatedUserId = schema.safeParse(userId); + if (!validatedUserId.success) { + throw new Error("Invalid user id"); + } + return validatedUserId.data; };