|
|
@ -182,3 +182,24 @@ module.exports.updateProfile = async (req, res) => {
|
|
|
|
res.status(500).json({ error: 'Internal Server Error' });
|
|
|
|
res.status(500).json({ error: 'Internal Server Error' });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// getting user name by id
|
|
|
|
|
|
|
|
exports.getUserName = async (req, res) => {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const { userId } = req.body;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Find the product by userId
|
|
|
|
|
|
|
|
const user = await User.findOne({ _id: userId });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!user) {
|
|
|
|
|
|
|
|
return res.status(404).json({ error: 'User not found' });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Send the user name in the response
|
|
|
|
|
|
|
|
res.json(user);
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
console.error('Error getting user name:', error);
|
|
|
|
|
|
|
|
res.status(500).json({ error: 'Internal Server Error' });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|