Cập nhật avatar và chỉnh sửa thông tin người dùng

This commit is contained in:
2026-06-09 15:21:22 +07:00
parent fd1027203d
commit 7f32eb816c
4 changed files with 205 additions and 28 deletions
+23
View File
@@ -907,6 +907,29 @@ router.put('/me/profile', protect, async (req, res) => {
}
});
/**
* @route GET /api/assets/view_avatar/:filename
* @desc Securely stream user avatar images
* @access Public (No auth needed for avatars)
*/
router.get('/assets/view_avatar/:filename', (req, res) => {
try {
const filename = req.params.filename;
const avatarPath = path.join(uploadDir, filename);
if (!fs.existsSync(avatarPath)) {
return res.status(404).json({ message: 'Avatar not found' });
}
res.sendFile(avatarPath, {
maxAge: 2592000000, // 30 ngày
headers: { 'Content-Type': 'image/jpeg' }
});
} catch (error) {
res.status(500).json({ message: error.message });
}
});
/**
* @route GET /api/me/scenes
* @desc Lấy danh sách các cảnh mẹ do người dùng tạo