fix: get auth user's id

This commit is contained in:
Rohit Rajan
2025-12-04 15:11:04 +05:30
parent 6986ba0700
commit 084f2a1b7f

View File

@@ -210,12 +210,13 @@ router.get(
requireSignIn,
async (req: AuthenticatedRequest, res) => {
try {
const { id } = req.params;
if (!id) {
return res.status(400).json({ message: "User ID is required" });
if (!req.user || !req.user.id) {
return res.status(401).json({ message: "Unauthorized" });
}
const user = await User.findByPk(id, {
const userId = req.user.id;
const user = await User.findByPk(userId, {
attributes: { exclude: ["password"] },
});