From f5faae79070043194e1af52fe8e23b0e42764752 Mon Sep 17 00:00:00 2001 From: "xingzhe.ru" Date: Thu, 3 Jul 2025 11:13:17 +0000 Subject: [PATCH] update server/routers/back-new/features/auth/auth.controller.js --- server/routers/back-new/features/auth/auth.controller.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server/routers/back-new/features/auth/auth.controller.js b/server/routers/back-new/features/auth/auth.controller.js index 21c400f..f97b846 100644 --- a/server/routers/back-new/features/auth/auth.controller.js +++ b/server/routers/back-new/features/auth/auth.controller.js @@ -92,4 +92,13 @@ exports.logout = (req, res) => { }), _meta: {} }); +}; + +exports.updateProfile = (req, res) => { + const userId = req.user?.id || req.body.id; // 这里假设有用户认证中间件,否则用body.id + if (!userId) return res.status(401).json({ error: 'Unauthorized' }); + const { firstName, lastName, bio, location, website } = req.body; + const updated = require('../../shared/usersDb').updateUser(userId, { firstName, lastName, bio, location, website }); + if (!updated) return res.status(404).json({ error: 'User not found' }); + res.json({ success: true, user: updated }); }; \ No newline at end of file