update server/routers/back-new/features/auth/auth.controller.js
This commit is contained in:
@@ -97,8 +97,8 @@ exports.logout = (req, res) => {
|
|||||||
exports.updateProfile = (req, res) => {
|
exports.updateProfile = (req, res) => {
|
||||||
const userId = req.user?.id || req.body.id; // 这里假设有用户认证中间件,否则用body.id
|
const userId = req.user?.id || req.body.id; // 这里假设有用户认证中间件,否则用body.id
|
||||||
if (!userId) return res.status(401).json({ error: 'Unauthorized' });
|
if (!userId) return res.status(401).json({ error: 'Unauthorized' });
|
||||||
const { firstName, lastName, bio, location, website } = req.body;
|
const { firstName, lastName, bio, location, website, email, username, password } = req.body;
|
||||||
const updated = require('../../shared/usersDb').updateUser(userId, { firstName, lastName, bio, location, website });
|
const updated = require('../../shared/usersDb').updateUser(userId, { firstName, lastName, bio, location, website, email, username, password });
|
||||||
if (!updated) return res.status(404).json({ error: 'User not found' });
|
if (!updated) return res.status(404).json({ error: 'User not found' });
|
||||||
res.json({ success: true, user: updated });
|
res.json({ success: true, user: updated });
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user