From 9557fa7d07d00cf6cc19673a422092f2abd2dd1d Mon Sep 17 00:00:00 2001 From: muken Date: Fri, 3 Jul 2026 00:14:32 -0500 Subject: [PATCH] fix: logged-in users can now comment without entering personal info - Fix user data extraction in rooms page (was looking for j.user instead of direct fields) - Add email to /api/auth/me response for logged-in user display - User object now properly populated with id, username, role, first_name, last_name, email, comments_disabled - Comments section now correctly shows 'Posting as {name}' for logged-in users - Reservations and messages already use user info when logged in, only require guest info for guests --- src/app/api/auth/me/route.ts | 3 ++- src/app/rooms/page.tsx | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/app/api/auth/me/route.ts b/src/app/api/auth/me/route.ts index c36e8ff..b641410 100644 --- a/src/app/api/auth/me/route.ts +++ b/src/app/api/auth/me/route.ts @@ -8,7 +8,7 @@ export async function GET() { return NextResponse.json({ authenticated: false }, { status: 401 }); } const { rows } = await db.query( - 'SELECT id, username, role, first_name, last_name, comments_disabled FROM users WHERE id = $1', + 'SELECT id, username, role, first_name, last_name, email, comments_disabled FROM users WHERE id = $1', [session.id] ); const user = rows[0] || {}; @@ -19,6 +19,7 @@ export async function GET() { id: session.id, first_name: user.first_name || null, last_name: user.last_name || null, + email: user.email || null, comments_disabled: user.comments_disabled === true, }); } diff --git a/src/app/rooms/page.tsx b/src/app/rooms/page.tsx index 267567a..0de239f 100644 --- a/src/app/rooms/page.tsx +++ b/src/app/rooms/page.tsx @@ -87,7 +87,21 @@ export default function RoomsPage() { fetch('/api/auth/me', { credentials: 'same-origin' }) .then((r) => r.json()) - .then((j) => setUser(j.user || null)) + .then((j) => { + if (j.authenticated) { + setUser({ + id: j.id, + username: j.username, + role: j.role, + first_name: j.first_name, + last_name: j.last_name, + email: j.email, + comments_disabled: j.comments_disabled, + }); + } else { + setUser(null); + } + }) .catch(() => {}); }, []);