feat: sync backend with frontend - add all UserEquity fields (brandIcon, brandIconImage, brandColor, platformType, hasUsedBenefit, benefit sub-fields, etc.) and new routes

This commit is contained in:
Developer
2026-05-13 20:08:48 +08:00
parent 519f4c2def
commit 9c52975b5a
17 changed files with 1613 additions and 1 deletions
+8
View File
@@ -2,6 +2,7 @@ const express = require('express');
const router = express.Router();
const { auth } = require('../middleware/auth');
const User = require('../models/User');
const { downloadAndSaveAvatar } = require('../services/avatarService');
router.get('/profile', auth, async (req, res, next) => {
try {
@@ -27,6 +28,13 @@ router.put('/profile', auth, async (req, res, next) => {
}
});
if (updates.avatarUrl && updates.avatarUrl.startsWith('http')) {
const savedAvatarUrl = await downloadAndSaveAvatar(updates.avatarUrl);
if (savedAvatarUrl) {
updates.avatarUrl = savedAvatarUrl;
}
}
const user = await User.findByIdAndUpdate(
req.user._id,
updates,