feat: updated backend logic for /me endpoint
This commit is contained in:
parent
6ad678af49
commit
f15ad83220
@ -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 });
|
||||
}
|
||||
);
|
||||
|
@ -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());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user