feat: updated backend logic for /me endpoint

This commit is contained in:
Angie 2025-07-25 00:15:44 +02:00
parent 6ad678af49
commit f15ad83220
2 changed files with 6 additions and 4 deletions

View File

@ -68,20 +68,19 @@ router.post(
}
);
// Get current user
router.get("/me", verifyToken, (req, res) => {
db.get(
"SELECT id, username, name, role FROM users WHERE id = ?",
"SELECT id, username, fullName, role FROM users WHERE id = ?",
[req.user.userId],
(err, user) => {
if (err) {
return res.status(500).json({ error: "Database error" });
}
if (!user) {
return res.status(404).json({ error: "User not found" });
}
// Ensure name field exists for frontend (even if null)
user.fullName = user.fullName || "";
res.json({ user });
}
);

View File

@ -26,6 +26,9 @@ app.use(
})
);
console.log("Loaded ENV PORT:", process.env.PORT);
console.log("Loaded ENV FRONTEND_URL:", process.env.FRONTEND_URL);
// Compression
app.use(compression());