完成个人信息的修改接口

master^2
P-Jhao 2 days ago
parent 4e676ea6bd
commit 94ef291099

@ -44,7 +44,12 @@ router.get("/whoami", async function (req, res, next) {
}) })
router.put("/", 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; module.exports = router;

@ -30,13 +30,17 @@ module.exports.loginService = async function (loginInfo) {
} }
} }
module.exports.updateUserInfoService = async function (loginInfo) { module.exports.updateUserInfoService = async function (userInfo) {
const data = loginInfo const data = userInfo
data.loginPwd = md5(data.loginPwd) data.loginPwd = md5(data.loginPwd)
await updateUserDao(data) await updateUserDao(data)
const { const {
loginPwd, loginPwd,
...result ...result
} = loginInfo } = userInfo
return result //重新赋值token
return {
token: getJwtToken(result),
data: result
}
} }
Loading…
Cancel
Save