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
This commit is contained in:
2026-07-03 00:14:32 -05:00
parent 200784fa49
commit 9557fa7d07
2 changed files with 17 additions and 2 deletions
+2 -1
View File
@@ -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,
});
}
+15 -1
View File
@@ -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(() => {});
}, []);