From 13a2acb17277cfaacebee2cf35fdecb4fb019c35 Mon Sep 17 00:00:00 2001 From: vyshnav Date: Thu, 12 Sep 2024 20:33:21 +0530 Subject: [PATCH] Refactor: Update auth-options.ts to include user id in session --- src/lib/auth-options.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/auth-options.ts b/src/lib/auth-options.ts index 913bafd..7ae3e61 100644 --- a/src/lib/auth-options.ts +++ b/src/lib/auth-options.ts @@ -9,6 +9,7 @@ import { JWT } from "next-auth/jwt"; declare module "next-auth" { interface Session { user: { + id: string; role: UserRoleType; } & DefaultSession["user"]; } @@ -34,6 +35,7 @@ export const authOptions: NextAuthOptions = { if (user) { return { ...token, + id: user.id, role: user.role, }; } @@ -45,6 +47,7 @@ export const authOptions: NextAuthOptions = { ...session, user: { ...session.user, + id: token.id, role: token.role as UserRoleType, }, };