From f2efa772d6db13d492a4b1a25384b4018c11a933 Mon Sep 17 00:00:00 2001 From: ilia Date: Sun, 4 Jan 2026 12:42:41 -0500 Subject: [PATCH] feat: Enhance logging and session handling in PhotosPage - Added detailed logging for session information in the PhotosPage component to aid in debugging. - Included console logs for session presence and user details, as well as a log for redirection to the login page when no session is found. - Updated session callback in auth.ts to include additional session details for improved context during authentication. --- app/photos/page.tsx | 8 ++++++++ lib/auth.ts | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/photos/page.tsx b/app/photos/page.tsx index 97d698c..ee3b88b 100644 --- a/app/photos/page.tsx +++ b/app/photos/page.tsx @@ -10,8 +10,16 @@ export const revalidate = 60 // Revalidate every 60 seconds export default async function PhotosPage() { const session = await auth() + + console.log("PhotosPage: auth() returned", { + hasSession: !!session, + sessionType: typeof session, + sessionUser: session?.user, + sessionKeys: session ? Object.keys(session) : [] + }) if (!session) { + console.log("PhotosPage: No session, redirecting to login") redirect("/login") } diff --git a/lib/auth.ts b/lib/auth.ts index 66f91c6..846c383 100644 --- a/lib/auth.ts +++ b/lib/auth.ts @@ -89,7 +89,10 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ email: token.email, hasUser: !!session.user, userKeys: session.user ? Object.keys(session.user) : [], - userRole: token.role + userRole: token.role, + sessionUser: session.user, + sessionExpires: session.expires, + fullSession: JSON.stringify(session, null, 2) }) } else { console.warn("Session callback: token missing or invalid", {