Merge pull request #914 from getmaxun/id-fix

fix: user id error handling
This commit is contained in:
Karishma Shukla
2025-12-05 23:19:36 +05:30
committed by GitHub

View File

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