From 94ef29109903cefbbb45cc47777e54f5d6b776b9 Mon Sep 17 00:00:00 2001 From: P-Jhao <113034340+P-Jhao@users.noreply.github.com> Date: Wed, 20 Nov 2024 14:59:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=B8=AA=E4=BA=BA=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E7=9A=84=E4=BF=AE=E6=94=B9=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routes/user.js | 7 ++++++- services/userService.js | 12 ++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/routes/user.js b/routes/user.js index 5503629..a465969 100644 --- a/routes/user.js +++ b/routes/user.js @@ -44,7 +44,12 @@ router.get("/whoami", async function (req, res, next) { }) router.put("/", async function (req, res, next) { - res.send(formatResponse(0, "", await updateUserInfoService(req.body))) + const { + token, + data + } = await updateUserInfoService(req.body) + res.setHeader("authentication", token) + res.send(formatResponse(0, "", data)) }) module.exports = router; \ No newline at end of file diff --git a/services/userService.js b/services/userService.js index e7639c6..984881f 100644 --- a/services/userService.js +++ b/services/userService.js @@ -30,13 +30,17 @@ module.exports.loginService = async function (loginInfo) { } } -module.exports.updateUserInfoService = async function (loginInfo) { - const data = loginInfo +module.exports.updateUserInfoService = async function (userInfo) { + const data = userInfo data.loginPwd = md5(data.loginPwd) await updateUserDao(data) const { loginPwd, ...result - } = loginInfo - return result + } = userInfo + //重新赋值token + return { + token: getJwtToken(result), + data: result + } } \ No newline at end of file