fix: correct user authentication check in messages page

The /api/auth/me endpoint returns { authenticated: true, id, username, ... }
not { user: {...} }. Fixed the messages page to correctly parse the response.
This commit is contained in:
2026-07-03 00:11:09 -05:00
parent 6c8d70d41c
commit 0785facd9e
+11 -1
View File
@@ -53,7 +53,17 @@ export default function MessagesPage() {
const res = await fetch('/api/auth/me');
if (res.ok) {
const data = await res.json();
setUser(data.user);
if (data.authenticated) {
setUser({
id: data.id,
username: data.username,
first_name: data.first_name,
last_name: data.last_name,
role: data.role,
});
} else {
window.location.href = '/login';
}
} else {
window.location.href = '/login';
}