From 18576f43b9959a224dd7965556628357b19f350e Mon Sep 17 00:00:00 2001 From: admineral <50579369+admineral@users.noreply.github.com> Date: Mon, 27 Nov 2023 22:14:06 +0100 Subject: [PATCH] Convert uid to string for consistent comparison with session.user.id --- app/actions.ts | 3 ++- auth.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/actions.ts b/app/actions.ts index 2c8a5dd..7fe08a7 100644 --- a/app/actions.ts +++ b/app/actions.ts @@ -49,7 +49,8 @@ export async function removeChat({ id, path }: { id: string; path: string }) { } } - const uid = await kv.hget(`chat:${id}`, 'userId') + //Convert uid to string for consistent comparison with session.user.id + const uid = String(await kv.hget(`chat:${id}`, 'userId')) if (uid !== session?.user?.id) { return { diff --git a/auth.ts b/auth.ts index a9f8abb..7c0c6a0 100644 --- a/auth.ts +++ b/auth.ts @@ -18,14 +18,14 @@ export const { callbacks: { jwt({ token, profile }) { if (profile) { - token.id = String(profile.id); // Convert profile.id to a string + token.id = profile.id token.image = profile.avatar_url || profile.picture } return token }, session: ({ session, token }) => { if (session?.user && token?.id) { - session.user.id = String(token.id); // Convert token.id to a string + session.user.id = String(token.id) } return session },