From 003bcac6234596dad7c8a2ee2e31e83bbffb9f67 Mon Sep 17 00:00:00 2001 From: chaosBreaking Date: Sat, 7 Sep 2019 22:04:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B5=84=E9=87=91=E5=AF=86=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/user/user.controller.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/modules/user/user.controller.js b/src/modules/user/user.controller.js index ccd07e7..6977da2 100644 --- a/src/modules/user/user.controller.js +++ b/src/modules/user/user.controller.js @@ -93,11 +93,13 @@ module.exports = { const { userId } = res.locals.user; const { password, newPassword } = req.body; return User.findById(userId).then(async user => { - const hashPasswd = Crypto.hash(password); - if (user.fundPwd !== hashPasswd) return res.json({ - code: 1, - msg: '原资金密码不正确' - }); + if (user.fundPwd) { + const hashPasswd = Crypto.hash(password); + if (user.fundPwd !== hashPasswd) return res.json({ + code: 1, + msg: '原资金密码不正确' + }); + } const newHashFundPwd = Crypto.hash(newPassword); user.updateOne({ fundPwd: newHashFundPwd }).then(() => { return res.json({